setBaseErrorOptions()function
setBaseErrorOptions(defaultCaller: AnyCaller, error: BaseError, options: BaseErrorOptions): void
| Param | Type | |
|---|---|---|
defaultCaller | AnyCaller | Function to attribute the stack to when options.caller is not supplied. required |
error | BaseError | The BaseError instance to mutate with contextual data and a trimmed stack. required |
options | BaseErrorOptions | |
.caller | AnyCaller | Modify the stack to trim off lines after a certain calling function. |
| Return | |
|---|---|
void | Nothing — error is mutated in place. |
Apply BaseErrorOptions to an error instance by copying contextual fields onto it and trimming its stack.
- Copies every option except
causeandcalleronto the error as a named property. - Uses
Error.captureStackTrace()with the resolved caller so the stack points at the user's call site, not the error plumbing.
Examples
const error = new ValueError("Wrong");
setBaseErrorOptions(ValueError, error, { received: 123, caller: myFunction });