Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ultirequiem/nested_error

⚠️ Error objects with nested Errors in stacktraces.
https://github.com/ultirequiem/nested_error

deno errors javascript node nodejs npm typescript

Last synced: 16 days ago
JSON representation

⚠️ Error objects with nested Errors in stacktraces.

Awesome Lists containing this project

README

        

# nested_error

[![Code Coverage](https://codecov.io/gh/ultirequiem/nested_error/branch/main/graph/badge.svg)](https://codecov.io/gh/ultirequiem/nested_error)
[![Deno Doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/nested_error/mod.ts)

Error objects with nested Errors in stacktraces.

## Usage

### [Deno 🦕](https://deno.land/x/nested_error)

```typescript
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 🐢](https://npmjs.com/package/@ultirequiem/nested-error)

```javascript
import { NestedError } from "@ultirequiem/nested-error";
```

### Browser

You can use any [CDN](https://en.wikipedia.org/wiki/Content_delivery_network) 🔥

Eg. [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
▶ [SkyPack](https://cdn.skypack.dev/@ultirequiem/nested-error) _/_
[script tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script) ▶
[JSDelivr](https://cdn.jsdelivr.net/npm/@ultirequiem/nested-error).

_The API is the same on all this platforms._

## Documentation

[Autogenerated Documentation](https://doc.deno.land/https://deno.land/x/nested_error/mod.ts)
📖

## 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](https://twitter.com/intent/tweet?text=%40UltiRequiem%20) 😆

Consider [supporting me on Patreon](https://patreon.com/UltiRequiem) if you like
my work 🚀

Don't forget to start the repo ⭐

## Versioning

We use [SemVer](http://semver.org) for versioning. For the versions available,
see the [tags](https://github.com/UltiRequiem/nested_error/tags).

## Authors

[Eliaz Bobadilla (a.k.a UltiRequiem)](https://ultirequiem.com) - Creator and
Maintainer 💪

See also the full list of
[contributors](https://github.com/UltiRequiem/nested_error/contributors) who
participated in this project.

## Licence

Licensed under the MIT License.