@ultirequiem/nested-error
v2.0.5
Published
Errors that keep their nested causes in the stack trace.
Maintainers
Readme
nested_error
Errors that keep their nested causes in the stack trace.
Install
npm install @ultirequiem/nested-errorUsage
ESM only, types included: the same import works in Node.js, Bun and browsers.
import { NestedError } from "@ultirequiem/nested-error";
function sum(a: number, b: number) {
if (a === 4 || b === 4) {
throw new Error("The number 4 gives bad luck.");
}
return a + b;
}
try {
sum(1, 4);
} catch (error) {
const newError = new NestedError("Error while summing 1 and 4", error);
console.log(newError.stack);
}Will cause
error: Uncaught (in promise) Error: Error: There was an error while summing 1 and 4
at nestError (file:///home/ulti/repos/packages/nested-error/mod.js:53:18)
at file:///home/ulti/repos/packages/nested-error/example.ts:14:5
Caused By: Error: The number 4 gives bad luck.
at sum (file:///home/ulti/repos/packages/nested-error/example.ts:5:11)
at file:///home/ulti/repos/packages/nested-error/example.ts:11:1
throw new Error(nested.stack);
^
at nestError (file:///home/ulti/repos/packages/nested-error/mod.js:54:9)
at file:///home/ulti/repos/packages/nested-error/example.ts:14:5Support
Open an Issue, I will check it as soon as possible 👀
If you want to hurry me up a bit send me a tweet 😆
Don't forget to star the repo ⭐
Versioning
We use SemVer for versioning. For the versions available, see the tags.
Authors
Eliaz Bobadilla (a.k.a UltiRequiem) - Creator and Maintainer 💪
See also the full list of contributors who participated in this project.
Licence
Licensed under the MIT License.
