Thrown by onIntegrationEvent's wrapper when a delivered message
is refused before the application handler runs. One class rather than four
keeps the consumer's instanceof branch a single import, while reason
discriminates.
The message carries the whole diagnostic on its own — the reason, the
topic, and the expected against the observed type/version — because the
default in-memory composition's dispatch reporter flattens a rejection to
error.message in one log string, so on that path the structured fields
never reach an operator and the message is all that survives. The fields
serve an application's instanceof branch on a path that surfaces the error
object itself (a real broker's nack handler, or a bespoke sink on the
'custom' broker arm).
For reason: 'parse', the thrown parser error is carried as cause — a
schema error's field paths are the most useful diagnostic in the whole path.
The field is typed unknown and set verbatim: a parser that throws a
non-Error value (a string, most commonly) is preserved as-is, and the
rejection's own message still names the topic and reason without it.
IntegrationEventRejectedError(details: { reason: IntegrationEventRejectionReason; topic: string; expectedType: string; expectedVersion: number; detail: string; cause?: unknown; })
Creates the rejection. The message is composed here so every refusal reads the same way on the flattened log path.
details: { reason: IntegrationEventRejectionReason; topic: string; expectedType: string; expectedVersion: number; detail: string; cause?: unknown; }
The refusal's structured fields, the human-readable
detail naming the observed fault, and the parser's thrown value as
cause when reason is 'parse'
expectedType: string
The type the consuming definition expects.
expectedVersion: number
The version the consuming definition expects.
reason: IntegrationEventRejectionReason
Why the delivery was refused.
topic: string
The topic the message was consumed from.