Class DomainEventHandlerCascadedException
Thrown by the domain event dispatch behaviors and helper when the aggregate's
pending-event list no longer matches the entry snapshot at the end of dispatch.
The validation is strict: length must match AND each position must be reference-equal
to the snapshot, so any handler-caused mutation (raising new events, clearing via
AcceptChanges, replacing, reordering) triggers this exception. Handlers MUST
be side-effect-only. In the multi-aggregate tracked-dispatch variant, every aggregate
in the snapshot is validated and offenders are reported together in Offenders.
Note: this exception fires AFTER the inner TransactionalCommandBehavior commits.
The database state is durable, but the dispatch-stage response is failure-shaped.
Consumers retrying the same command will hit "already committed" semantics; durable
at-least-once dispatch requires the outbox pattern (planned, not shipped).
public sealed class DomainEventHandlerCascadedException : InvalidOperationException, ISerializable
- Inheritance
-
DomainEventHandlerCascadedException
- Implements
- Inherited Members
- Extension Methods
Constructors
DomainEventHandlerCascadedException()
Initializes a new instance of the DomainEventHandlerCascadedException class.
public DomainEventHandlerCascadedException()
DomainEventHandlerCascadedException(IReadOnlyList<CascadeOffender>)
Initializes a new instance of the DomainEventHandlerCascadedException class.
public DomainEventHandlerCascadedException(IReadOnlyList<CascadeOffender> offenders)
Parameters
offendersIReadOnlyList<CascadeOffender>The aggregates whose pending-event list changed during dispatch (handlers raised new events, cleared via
AcceptChanges, replaced, or reordered).
DomainEventHandlerCascadedException(string)
Initializes a new instance of the DomainEventHandlerCascadedException class.
public DomainEventHandlerCascadedException(string message)
Parameters
messagestringThe exception message.
DomainEventHandlerCascadedException(string, Exception)
Initializes a new instance of the DomainEventHandlerCascadedException class.
public DomainEventHandlerCascadedException(string message, Exception innerException)
Parameters
DomainEventHandlerCascadedException(Type, IReadOnlyList<string>)
Initializes a new instance of the DomainEventHandlerCascadedException class for one aggregate.
public DomainEventHandlerCascadedException(Type aggregateType, IReadOnlyList<string> cascadedEventTypeNames)
Parameters
aggregateTypeTypeThe offending aggregate type.
cascadedEventTypeNamesIReadOnlyList<string>The event type names still present at the first changed position after dispatch.
Properties
Offenders
Gets the aggregates whose pending-event list changed during dispatch.
public IReadOnlyList<CascadeOffender> Offenders { get; }