nested_error
Error objects with nested Errors in stacktraces.
Usage
Deno 🦕
import { NestedError } from "https://deno.land/x/nested_error/mod.ts";
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:5
Node.js 🐢
import { NestedError } from "@ultirequiem/nested-error";
Browser
You can use any CDN
Eg. ESM
The API is the same on all this platforms.
Documentation
Support
Open an Issue, I will check it a soon as possible
If you want to hurry me up a bit
send me a tweet
Consider supporting me on Patreon if you like
my work
Don't forget to start 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.