exitus
v1.2.2
Published
Typed error wrapping.
Downloads
21
Readme
exitus
Typed error wrapping.
Usage
Generic Errors - GenericExerr
With no arguments provided, exerr
will create a GenericExerr
.
const ohShucks = newError() satisfies GenericExerr;
Custom Error Codes
const ohWhat = exerr({
// Can be a number, symbol or string
code: 'INESCAPABLE_DOOM',
}) satisfies Exerr<"INESCAPABLE_DOOM">;
Debugging Options
Use these properties for assisting in debugging or internal logging.
const ohBrother = exerr({
message: "'... I bet <insert framework of choice> doesn't have these issues.'",
caughtException: new Error(),
context: {
someInput: 4124309184571,
someOutput: "pi == 4",
},
stack: true,
});
Guards
isExerr(ohWhat) // true
isExerr(new Error()) // false