ignore-errors
Easily ignore specific promise errors
Installation
npm i --save ignore-errors
Usage
Supports both ESM and CommonJS
// esm// commonjsconst ignore = default
Ignore errors that have a specific property value
Will ignore errors w/ property foo
that equals the given literal value (string, number, anything except a regexp)
const err = 'boom'errfoo = 'foobar'await Promise// gets here, no error thrown
Ignore errors have specified properties with values
Will ignore errors w/ 'foo' and 'bar' given expected values
var err = 'boom'errfoo = 1errbar = 2await Promise// gets here, no error thrown
Ignore errors have with property values that match a regexp
Will ignore errors w/ property foo
that have a value that matches the regexp
const err = 'boom'errfoo = 'foobar'await Promise// gets here, no error thrown // regexps work when passed when matching multiple properties tooconst err = 'boom'errfoo = 1errbar = 2await Promise
Convenience methods for common error properties
Easily ignore errors with messages
, names
, statuses
, reasons
or codes
let err // ignore errors with specific messageserr = 'boom'await Promiseawait Promise// gets here, no error thrown // ignore errors with specific names { supermessage thisname = thisconstructorname }err = 'boom'await Promiseawait Promise// gets here, no error thrown // ignore errors with specific statuseserr = 'boom'errstatus = 500await Promiseawait Promise// gets here, no error thrown // ignore errors with specific reasonserr = 'boom'errreason = 'BOOM_ERROR'await Promiseawait Promise// gets here, no error thrown // ignore errors with specific codeserr = 'boom'errcode = 10await Promiseawait Promise// gets here, no error thrown
ignoreAny
Easily ignore various types of errors with let err // ignore errors with specific messageserr = 'boom'await Promise// gets here, no error thrown
License
MIT