Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 17, 2024 via pnpm

error-ex 1.3.2

Easy error subclassing and stack customization
Package summary
Share
0
issues
1
license
2
MIT
Package created
25 Aug 2015
Version published
19 Jun 2018
Maintainers
2
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
error-ex@1.3.2
is-arrayish@0.2.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
β“˜ This is a list of error-ex 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
is-arrayish0.2.12.58 kBMIT
prod

Visualizations

Frequently Asked Questions

What does error-ex do?

Error-ex is a highly regarded Node.js package for easy error subclassing and stack customization. This npm package offers a convenient way to subclass and create unique Error types in a Node.js project enabling them to define more specific and user-friendly error information. Thus, enhancing the debugging process.

How do you use error-ex?

To incorporate error-ex into your Node.js project, first, you need to include it in your project file.

var errorEx = require('error-ex');

Creating a specific error message type is also quite simple using error-ex:

var JSONError = errorEx('JSONError');

var err = new JSONError('error');
err.name; // This will output "JSONError"
throw err; // Will throw an error "JSONError: error"

You can also add a stack line to the error message:

var JSONError = errorEx('JSONError', {fileName: errorEx.line('in %s')});

var err = new JSONError('error');
err.fileName = '/a/b/c/foo.json';
throw err; 
// This will throw an error displaying the stack line location in the file path: "in /a/b/c/foo.json"

Appending error messages can be achieved with the following snippet:

var JSONError = errorEx('JSONError', {fileName: errorEx.append('in %s')});

var err = new JSONError('error');
err.fileName = '/a/b/c/foo.json';
throw err; 
// Will throw an error "JSONError: error in /a/b/c/foo.json"

Where are the error-ex docs?

The error-ex documentation and usage specifics are available within the README file in the project's GitHub repository (https://github.com/qix-/node-error-ex). In addition to the detailed code examples, it describes the full API, including helper functions like errorEx.line(str) and errorEx.append(str) for creating stack lines and appending to the error.message string, respectively. The documentation provides a full breakdown of how to create new ErrorEx error types, including how to customize them with additional properties and methods.