Improved handling of standard errors.

Crash helps us manage standard errors within our application by providing us with some tools:

  • Association of errors and their causes in a hierarchical way.
  • Simple search for root causes within the hierarchy of errors.
  • Stack management, both of the current instance of the error, and of the causes.
  • Facilitate error logging.

In addition, in combination with the Multi error types, errors in validation processes, and Boom, errors for the REST-API interfaces, it allows a complete management of the different types of errors in our backend.

Hierarchy (View Summary)

Constructors

  • Create a new Crash error instance

    Parameters

    • message: string

      human friendly error message

    Returns Crash

  • Create a new Crash error

    Parameters

    • message: string

      human friendly error message

    • options: CrashOptions

      enhanced error options

    Returns Crash

  • Create a new Crash error

    Parameters

    • message: string

      human friendly error message

    • uuid: string

      unique identifier for this particular occurrence of the problem

    Returns Crash

  • Create a new Crash error

    Parameters

    • message: string

      human friendly error message

    • uuid: string

      unique identifier for this particular occurrence of the problem

    • options: CrashOptions

      enhanced error options

    Returns Crash

Properties

date: Date

Error date

name: string = 'BaseError'

Error name (type)

subject: string

Error subject, 'common' as default

Accessors

  • get cause(): undefined | Cause
  • Cause source of error

    Returns undefined | Cause

  • get info(): undefined | Record<string, unknown>
  • Return the info object for this error

    Returns undefined | Record<string, unknown>

  • get isCrash(): boolean
  • Determine if this instance is a Crash error

    Returns boolean

  • get uuid(): string
  • Return the unique identifier associated to this instance

    Returns string

Methods

  • Look in the nested causes of the error and return the first occurrence of a cause with the indicated name

    Parameters

    • name: string

      name of the error to search for

    Returns undefined | Cause

    the cause, if there is any present with that name

  • Returns a full stack of the error and causes hierarchically. The string contains the description of the point in the code at which the Error/Crash was instantiated

    Returns undefined | string

  • Check if there is any cause in the stack with the indicated name

    Parameters

    • name: string

      name of the error to search for

    Returns boolean

    Boolean value as the result of the search

  • Return a string formatted as name:message

    Returns string

  • Get the trace of this hierarchy of errors

    Returns string[]

  • Check if an object is a valid Crash or Multi error

    Parameters

    • error: unknown

      error to be checked

    • Optionaluuid: string

      Optional uuid to be used instead of a random one.

    Returns Crash | Multi