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.Events;
12 :
13 : namespace Cqrs.Domain.Exceptions
14 : {
15 : /// <summary>
16 : /// The <see cref="IAggregateRoot{TAuthenticationToken}"/> requested was not found.
17 : /// </summary>
18 : /// <typeparam name="TAggregateRoot">The <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that wasn't found.</typeparam>
19 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
20 : [Serializable]
21 : public class AggregateNotFoundException<TAggregateRoot, TAuthenticationToken> : Exception
22 : where TAggregateRoot : IAggregateRoot<TAuthenticationToken>
23 1 : {
24 : /// <summary>
25 : /// Instantiate a new instance of <see cref="AggregateNotFoundException{TAggregateRoot,TAuthenticationToken}"/> with the provided identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that wasn't found.
26 : /// </summary>
27 : /// <param name="id">The identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that wasn't found.</param>
28 1 : public AggregateNotFoundException(Guid id)
29 : : base(string.Format("Aggregate '{0}' of type '{1}' was not found", id, typeof(TAggregateRoot).FullName))
30 : {
31 : Id = id;
32 : AggregateType = typeof(TAggregateRoot);
33 : }
34 :
35 : /// <summary>
36 : /// The identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that wasn't found.
37 : /// </summary>
38 : [DataMember]
39 : public Guid Id { get; set; }
40 :
41 : /// <summary>
42 : /// The <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> that wasn't found.
43 : /// </summary>
44 : [DataMember]
45 : public Type AggregateType { get; set; }
46 : }
47 : }
|