Class DuplicateLegalHoldException
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Thrown by SaveHoldAsync(LegalHold, CancellationToken) when — and only when — a hold with the same HoldId is already stored.
public sealed class DuplicateLegalHoldException : InvalidOperationException, ISerializable
- Inheritance
-
DuplicateLegalHoldException
- Implements
- Inherited Members
Remarks
This type exists so that "the hold is already on file" is distinguishable by the caller from
every other reason a save can fail. Without it the duplicate signal and the fail-closed tenancy signal
are the same type: TenantRequiredException also derives from
InvalidOperationException and is raised, before any row is examined, when multi-tenancy
is active and no ambient tenant was resolved. A caller writing
catch (InvalidOperationException) { /* already filed */ } therefore treats a hold that was
never written as one that was — and a legal hold is a control that blocks erasure, so one
silently dropped does not fail safe: the next erasure runs and reports success.
It derives from InvalidOperationException because a duplicate insert genuinely is an
invalid operation on the store's current state, and because that keeps an existing broad
catch (InvalidOperationException) working. A caller that needs the duplicate signal specifically
must catch this type.
The identifier namespace this reports on is estate-wide, and that is deliberate. Every shipped relational provider declares the hold identifier as the table's sole primary key, so a hold identifier is unique across the whole estate rather than within one tenant. Under multi-tenancy that produces a pair of answers a caller can read as contradictory unless it is stated: this exception can be raised for a hold that GetHoldAsync(Guid, CancellationToken) reports as absent, because the colliding hold belongs to a tenant whose rows are — correctly — not visible. "The identifier is taken" and "you cannot see it" are both true. Callers that must not disclose whether an identifier is in use should allocate hold identifiers randomly rather than deriving them from a case reference or any other value another tenant could guess.
Implementations raise this rather than the underlying database provider's own duplicate-key exception, so a caller can handle the condition without referencing that provider or knowing its error codes. The provider's exception is preserved as InnerException so the underlying cause stays diagnosable.
Constructors
DuplicateLegalHoldException()
Initializes a new instance of the DuplicateLegalHoldException class.
public DuplicateLegalHoldException()
DuplicateLegalHoldException(string)
Initializes a new instance of the DuplicateLegalHoldException class with a message.
public DuplicateLegalHoldException(string message)
Parameters
messagestringThe error message.
DuplicateLegalHoldException(string, Exception?)
Initializes a new instance of the DuplicateLegalHoldException class with a message and inner exception.
public DuplicateLegalHoldException(string message, Exception? innerException)
Parameters
messagestringThe error message.
innerExceptionExceptionThe underlying store failure that reported the duplicate, when there was one.
Properties
HoldId
Gets the identifier of the hold that is already stored.
public Guid? HoldId { get; init; }
Property Value
Methods
ForHoldId(Guid, Exception?)
Creates an exception for a hold identifier that is already stored.
public static DuplicateLegalHoldException ForHoldId(Guid holdId, Exception? innerException = null)
Parameters
holdIdGuidThe hold identifier that was re-filed.
innerExceptionExceptionThe underlying store failure that reported the duplicate, if any.
Returns
- DuplicateLegalHoldException
The exception to throw.