1+ /*==============================================================================================================================
2+ | Author Ignia, LLC
3+ | Client Ignia, LLC
4+ | Project Topics Library
5+ \=============================================================================================================================*/
6+ using System ;
7+ using System . Runtime . Serialization ;
8+ using OnTopic . Internal . Diagnostics ;
9+
10+ namespace OnTopic . Repositories {
11+
12+ /*============================================================================================================================
13+ | CLASS: REFERENTIAL INTEGRITY EXCEPTION
14+ \---------------------------------------------------------------------------------------------------------------------------*/
15+ /// <summary>
16+ /// The <see cref="ReferentialIntegrityException"/> will be thrown when an operation violates the referential integrity of
17+ /// the underlying persistence layer.
18+ /// </summary>
19+ /// <remarks>
20+ /// Generally, the <see cref="ReferentialIntegrityException"/> will occur when a <see cref="Topic"/> is being
21+ /// deleted, but the topic or one of its descendents is the <see cref="Topic.DerivedTopic"/> of another <see cref="Topic"/>.
22+ /// In that case, deleting the topic will violate the referential integrity of the target topic.
23+ /// </remarks>
24+ [ Serializable ]
25+ public class ReferentialIntegrityException : TopicRepositoryException {
26+
27+ /*==========================================================================================================================
28+ | CONSTRUCTOR: REFERENTIAL INTEGRITY EXCEPTION
29+ \-------------------------------------------------------------------------------------------------------------------------*/
30+ /// <summary>
31+ /// Initializes a new <see cref="ReferentialIntegrityException" /> instance.
32+ /// </summary>
33+ public ReferentialIntegrityException ( ) : base ( ) { }
34+
35+ /// <summary>
36+ /// Initializes a new <see cref="ReferentialIntegrityException" /> instance based on the source <see cref=
37+ /// "Topic"/>.
38+ /// </summary>
39+ /// <param name="sourceTopic">The source <see cref="Topic"/> which triggered the exception.</param>
40+ public ReferentialIntegrityException ( Topic sourceTopic ) :
41+ base (
42+ $ "The operation on the topic '{ sourceTopic ? . DerivedTopic ? . GetUniqueKey ( ) } ' would introduce a referential integrity " +
43+ $ "violation in the underlying persistence layer; the topic '{ sourceTopic ? . GetUniqueKey ( ) } ' depends upon it."
44+ ) { }
45+
46+ /// <summary>
47+ /// Initializes a new <see cref="ReferentialIntegrityException" /> instance based on the source <see cref=
48+ /// "Topic"/>.
49+ /// </summary>
50+ /// <param name="sourceTopic">The source <see cref="Topic"/> which triggered the exception.</param>
51+ /// <param name="innerException">The reference to the original, underlying exception.</param>
52+ public ReferentialIntegrityException ( Topic sourceTopic , Exception innerException ) :
53+ base (
54+ $ "The operation on the topic '{ sourceTopic ? . DerivedTopic ? . GetUniqueKey ( ) } ' would introduce a referential integrity " +
55+ $ "violation in the underlying persistence layer; the topic '{ sourceTopic ? . GetUniqueKey ( ) } ' depends upon it.",
56+ innerException
57+ ) { }
58+
59+ /// <summary>
60+ /// Initializes a new <see cref="ReferentialIntegrityException" /> instance based on a <paramref name=
61+ /// "message"/>.
62+ /// </summary>
63+ /// <param name="message">The error message to associate with the exception.</param>
64+ public ReferentialIntegrityException ( string message ) : base ( message ) { }
65+
66+ /// <summary>
67+ /// Initializes a new <see cref="ReferentialIntegrityException" /> instance based on a <paramref name=
68+ /// "message"/>.
69+ /// </summary>
70+ /// <param name="message">The error message to associate with the exception.</param>
71+ /// <param name="innerException">The reference to the original, underlying exception.</param>
72+ public ReferentialIntegrityException ( string message , Exception innerException ) : base ( message , innerException ) { }
73+
74+ /// <summary>
75+ /// Instantiates a new <see cref="ReferentialIntegrityException"/> instance for serialization.
76+ /// </summary>
77+ /// <param name="info">A <see cref="SerializationInfo"/> instance with details about the serialization requirements.</param>
78+ /// <param name="context">A <see cref="StreamingContext"/> instance with details about the request context.</param>
79+ /// <returns>A new <see cref="InvalidKeyException"/> instance.</returns>
80+ protected ReferentialIntegrityException ( SerializationInfo info , StreamingContext context ) : base ( info , context ) {
81+ Contract . Requires ( info ) ;
82+ }
83+
84+ } //Class
85+ } //Namespace
0 commit comments