Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Runtime.Serialization;
11 : using Cqrs.Entities;
12 :
13 : namespace Cqrs.Domain.Exceptions
14 : {
15 : /// <summary>
16 : /// The <see cref="IEntity"/> requested was not found.
17 : /// </summary>
18 : /// <typeparam name="TEntity">The <see cref="Type"/> of the <see cref="IEntity"/> that wasn't found</typeparam>
19 : [Serializable]
20 : public class EntityNotFoundException<TEntity> : Exception
21 : where TEntity : IEntity
22 1 : {
23 : /// <summary>
24 : /// Instantiate a new instance of <see cref="EntityNotFoundException{TEntity}"/> with the provided identifier of the <see cref="IEntity"/> that wasn't found.
25 : /// </summary>
26 : /// <param name="id">The identifier of the <see cref="IEntity"/> that wasn't found.</param>
27 1 : public EntityNotFoundException(Guid id)
28 : : base(string.Format("Entity '{0}' of type '{1}' was not found", id, typeof(TEntity).FullName))
29 : {
30 : Id = id;
31 : EntityType = typeof(TEntity);
32 : }
33 :
34 : /// <summary>
35 : /// The identifier of the <see cref="IEntity"/> that wasn't found.
36 : /// </summary>
37 : [DataMember]
38 : public Guid Id { get; set; }
39 :
40 : /// <summary>
41 : /// The <see cref="Type"/> of the <see cref="IEntity"/> that wasn't found.
42 : /// </summary>
43 : [DataMember]
44 : public Type EntityType { get; set; }
45 : }
46 : }
|