Class: Errors

Errors()

Utilities for working with errors

Constructor

new Errors()

Methods

(static) matches(err, matcher) → {boolean}

Check whether a thrown value or Error matches a specified condition.

Supports:

  • Functions: matcher(err) returns boolean
  • Primitives: equality check (===)
  • Error instances: matches constructor name, statusCode, or message
  • Strings: can be matched by a RegExp
Parameters:
Name Type Description
err *

The thrown value (can be primitive, string, or Error)

matcher string | number | RegExp | function

Matching condition

Returns:

True if err matches matcher, false otherwise

Type
boolean