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="IEventStore{TAuthenticationToken}"/> gave more than one event.
17 : /// </summary>
18 : /// <typeparam name="TSaga">The <see cref="Type"/> of the <see cref="ISaga{TAuthenticationToken}"/> that wasn't found.</typeparam>
19 : /// <typeparam name="TAuthenticationToken">The <see cref="Type"/> of the authentication token.</typeparam>
20 : [Serializable]
21 : public class DuplicateSagaEventException<TSaga, TAuthenticationToken> : Exception
22 : where TSaga : ISaga<TAuthenticationToken>
23 1 : {
24 : /// <summary>
25 : /// Instantiate a new instance of <see cref="DuplicateSagaEventException{TAggregateRoot,TAuthenticationToken}"/> with the provided identifier of the <see cref="ISaga{TAuthenticationToken}"/> that had duplicate <see cref="IEvent{TAuthenticationToken}">events</see>.
26 : /// and the <paramref name="version"/> that had more than one <see cref="IEvent{TAuthenticationToken}"/> provided.
27 : /// </summary>
28 : /// <param name="id">The identifier of the <see cref="ISaga{TAuthenticationToken}"/> that had <see cref="IEvent{TAuthenticationToken}">events</see>.</param>
29 : /// <param name="version">The version number of the duplicate <see cref="IEvent{TAuthenticationToken}">events</see></param>
30 1 : public DuplicateSagaEventException(Guid id, int version)
31 : : base(string.Format("Eventstore gave more than one event for saga '{0}' of type '{1}' for version {2}", id, typeof(TSaga).FullName, version))
32 : {
33 : Id = id;
34 : SagaType = typeof(TSaga);
35 : }
36 :
37 : /// <summary>
38 : /// The identifier of the <see cref="ISaga{TAuthenticationToken}"/> that had duplicate <see cref="IEvent{TAuthenticationToken}">events</see>..
39 : /// </summary>
40 : [DataMember]
41 : public Guid Id { get; set; }
42 :
43 : /// <summary>
44 : /// The <see cref="Type"/> of the <see cref="ISaga{TAuthenticationToken}"/> that had duplicate <see cref="IEvent{TAuthenticationToken}">events</see>..
45 : /// </summary>
46 : [DataMember]
47 : public Type SagaType { get; set; }
48 : }
49 : }
|