What is errlop?
Errlop is a utility for creating and managing error objects in JavaScript. It allows you to wrap errors, add additional context, and handle them in a more structured way.
What are errlop's main functionalities?
Creating a basic Errlop error
This feature allows you to create a basic Errlop error with a custom message.
const Errlop = require('errlop');
const error = new Errlop('Something went wrong');
console.log(error.message);
Wrapping an existing error
This feature allows you to wrap an existing error with a new Errlop error, preserving the original error as the cause.
const Errlop = require('errlop');
const originalError = new Error('Original error');
const wrappedError = new Errlop('Something went wrong', originalError);
console.log(wrappedError.message);
console.log(wrappedError.cause);
Adding additional context
This feature allows you to add additional context to an Errlop error, which can be useful for debugging.
const Errlop = require('errlop');
const error = new Errlop('Something went wrong', { context: 'Additional context' });
console.log(error.context);
Other packages similar to errlop
verror
VError is a library for creating and managing nested errors in JavaScript. It allows you to wrap errors and add additional context, similar to Errlop. However, VError provides more advanced features for error handling, such as error codes and multi-error support.
error-stack-parser
Error Stack Parser is a library for parsing and extracting information from error stack traces. While it does not provide the same error wrapping functionality as Errlop, it is useful for analyzing and debugging errors by extracting meaningful information from stack traces.
stacktrace-js
Stacktrace.js is a library for generating, parsing, and analyzing stack traces in JavaScript. It provides more advanced stack trace manipulation capabilities compared to Errlop, but does not focus on error wrapping and context management.
errlop
![Wishlist browse button](https://img.shields.io/badge/wishlist-donate-yellow.svg)
An extended Error class that envelops a parent error, such that the stack trace contains the causation
Usage
Complete API Documentation.
import Errlop from 'errlop'
const a = new Errlop('AError')
const b = new Errlop('BError', a)
const c = Errlop.create('CError', b)
console.log(c.stack)
console.log(c.orphanStack)
Install
- Install:
npm install --save errlop
- Import:
import pkg from ('errlop')
- Require:
const pkg = require('errlop').default
import pkg from 'https://unpkg.com/errlop@^3.14.0/edition-deno/index.ts'
<script type="module">
import pkg from '//cdn.pika.dev/errlop/^3.14.0'
</script>
<script type="module">
import pkg from '//unpkg.com/errlop@^3.14.0'
</script>
<script type="module">
import pkg from '//dev.jspm.io/errlop@3.14.0'
</script>
This package is published with the following editions:
errlop/source/index.ts
is TypeScript source code with Import for moduleserrlop/edition-browsers/index.js
is TypeScript compiled against ES2019 for web browsers with Import for moduleserrlop
aliases errlop/edition-es5/index.js
errlop/edition-es5/index.js
is TypeScript compiled against ES5 for Node.js with Require for moduleserrlop/edition-node-esm/index.js
is TypeScript compiled against ES5 for Node.js with Import for moduleserrlop/edition-deno/index.ts
is TypeScript source code made to be compatible with Deno
History
Discover the release history by heading on over to the HISTORY.md
file.
Contribute
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
Backers
Maintainers
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
![Wishlist browse button](https://img.shields.io/badge/wishlist-donate-yellow.svg)
Contributors
These amazing people have contributed code to this project:
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
License
Unless stated otherwise all works are:
and licensed under: