Creates the rejection. The message is composed here so every refusal reads the same way on the flattened log path.
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'
OptionalcauseReadonlyexpectedThe type the consuming definition expects.
ReadonlyexpectedThe version the consuming definition expects.
ReadonlyreasonWhy the delivery was refused.
OptionalstackReadonlytopicThe topic the message was consumed from.
StaticstackThe Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
StaticcaptureCreates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
OptionalconstructorOpt: FunctionStaticprepare
Thrown by
onIntegrationEvent's wrapper when a delivered message is refused before the application handler runs. One class rather than four keeps the consumer'sinstanceofbranch a single import, whilereasondiscriminates.The
messagecarries the whole diagnostic on its own — the reason, the topic, and the expected against the observedtype/version— because the default in-memory composition's dispatch reporter flattens a rejection toerror.messagein 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'sinstanceofbranch 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 ascause— a schema error's field paths are the most useful diagnostic in the whole path. The field is typedunknownand set verbatim: a parser that throws a non-Errorvalue (a string, most commonly) is preserved as-is, and the rejection's own message still names the topic and reason without it.Since
0.6.0