suppressed-error

1.0.3 • Public • Published

suppressed-error Version Badge

github actions coverage License Downloads

npm badge

ES Proposal spec-compliant shim for SuppressedError. Invoke its "shim" method to shim SuppressedError if it is unavailable or noncompliant.

This package implements the es-shim API interface. It works in an ES3-supported environment, and complies with the proposed spec.

Most common usage:

var assert = require('assert');
var SuppressedError = require('suppressed-error');

var suppressedError = new RangeError('hi!');
var cause = new EvalError('oops');
var error = new SuppressedError(cause, suppressedError, 'this is a suppressed error');

assert.equal(error.error, cause); // this is the cause of the suppression
assert.equal(error.suppressed, suppressedError);
assert.equal(error.message, 'this is a suppressed error');

SuppressedError.shim(); // will be a no-op if not needed

assert.ok(new globalThis.SuppressedError(null, '', {}) instanceof SuppressedError);

Tests

Simply clone the repo, npm install, and run npm test

Package Sidebar

Install

npm i suppressed-error

Weekly Downloads

6,633

Version

1.0.3

License

MIT

Unpacked Size

16.2 kB

Total Files

18

Last publish

Collaborators

  • ljharb