Options
All
  • Public
  • Public/Protected
  • All
Menu

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

  • Base
    • Crash

Index

Constructors

constructor

  • 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

message

message: string

name

name: string = 'BaseError'

Error name (type)

Optional stack

stack?: string

Static Optional prepareStackTrace

prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Type declaration

    • (err: Error, stackTraces: CallSite[]): any
    • Optional override for formatting stack traces

      Parameters

      • err: Error
      • stackTraces: CallSite[]

      Returns any

Static stackTraceLimit

stackTraceLimit: number

Accessors

cause

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

    Returns undefined | Cause

info

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

    Returns undefined | Record<string, unknown>

isCrash

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

    Returns boolean

uuid

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

    Returns string

Methods

findCauseByName

  • findCauseByName(name: string): undefined | Cause
  • 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

fullStack

  • fullStack(): undefined | string
  • 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

hasCauseWithName

  • hasCauseWithName(name: string): boolean
  • 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

toJSON

toString

  • toString(): string
  • Return a string formatted as name:message

    Returns string

trace

  • trace(): string[]
  • Get the trace of this hierarchy of errors

    Returns string[]

Static captureStackTrace

  • captureStackTrace(targetObject: object, constructorOpt?: Function): void
  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • Optional constructorOpt: Function

    Returns void

Generated using TypeDoc