Class LegalHoldConcurrencyException
- Namespace
- Excalibur.Compliance
- Assembly
- Excalibur.Compliance.Abstractions.dll
Thrown by UpdateHoldAsync(LegalHold, CancellationToken) when — and only when — the stored hold is present and visible, but carries a Version other than the one the caller read. The write is not applied.
public sealed class LegalHoldConcurrencyException : InvalidOperationException, ISerializable
- Inheritance
-
LegalHoldConcurrencyException
- Implements
- Inherited Members
Remarks
Why this is an exception rather than a return value. A legal hold is the authority that stops an erasure destroying records a data controller is legally obliged to keep. The update path is a read-modify-write: a caller reads a hold, decides from what it read, and writes the whole record back. Without a version check that decision is applied over whatever the record became in the meantime, so a hold extended between the read and the write is released anyway and the next erasure for that subject proceeds. The loss is not of the hold — it is of the records the hold protected, and it is irreversible.
That failure is silent, which is what sets the reporting bar here. The released record is
well-formed and carries a plausible reason, so an auditor inspecting it afterwards sees a legitimate
release; the extension simply is not there, and nothing downstream learns that the erasure which
followed was unlawful. A conflict signalled as a bool or an enum can be discarded at
the call site — both shipped call sites did exactly that, writing _ = await … — and a discarded
conflict reproduces the silence one layer up. An exception cannot be dropped by accident.
It derives from InvalidOperationException for the same reason DuplicateLegalHoldException does: writing over a record that moved genuinely is an invalid operation on the store's current state. A caller that needs the conflict signal specifically must catch this type — and it is distinct from DuplicateLegalHoldException because the remedies differ. A duplicate means the identifier is taken; a conflict means the caller's premise expired, so the correct response is to re-read and re-decide, never to re-apply the same write with a fresh version. Re-applying it reintroduces the lost update with extra steps.
A hold that is absent, or that belongs to another tenant, is not reported here: UpdateHoldAsync(LegalHold, CancellationToken) returns false for those, so "nothing to write to" stays distinguishable from "the record moved under you".
Constructors
LegalHoldConcurrencyException()
Initializes a new instance of the LegalHoldConcurrencyException class.
public LegalHoldConcurrencyException()
LegalHoldConcurrencyException(string)
Initializes a new instance of the LegalHoldConcurrencyException class with a message.
public LegalHoldConcurrencyException(string message)
Parameters
messagestringThe error message.
LegalHoldConcurrencyException(string, Exception?)
Initializes a new instance of the LegalHoldConcurrencyException class with a message and inner exception.
public LegalHoldConcurrencyException(string message, Exception? innerException)
Parameters
messagestringThe error message.
innerExceptionExceptionThe underlying store failure, when there was one.
Properties
ActualVersion
Gets the Version actually stored when the write was attempted.
public int? ActualVersion { get; init; }
Property Value
- int?
Remarks
Re-read the hold before deciding anything from this number. It says the record moved; it does not say what it moved to, and the difference is the whole point — a hold whose expiry was extended must stay active.
ExpectedVersion
Gets the Version the caller read and expected to still be stored.
public int? ExpectedVersion { get; init; }
Property Value
- int?
HoldId
Gets the identifier of the hold whose update was refused.
public Guid? HoldId { get; init; }
Property Value
Methods
ForHold(Guid, int, int, Exception?)
Creates an exception for a hold whose stored version no longer matches the one the caller read.
public static LegalHoldConcurrencyException ForHold(Guid holdId, int expectedVersion, int actualVersion, Exception? innerException = null)
Parameters
holdIdGuidThe hold identifier that was written to.
expectedVersionintThe version the caller read.
actualVersionintThe version actually stored.
innerExceptionExceptionThe underlying store failure, if any.
Returns
- LegalHoldConcurrencyException
The exception to throw.