1.0.3 • Published 11 months ago

suppressed-error v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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