Improved handling of validation errors.

Multi helps us to manage validation or information transformation errors, in other words, it helps us manage any process that may generate multiple non-hierarchical errors (an error is not a direct consequence of the previous one) by providing us with some tools:

  • Management of the error stack.
  • Simple search for root causes within the error stack.
  • Stack management, both of the current instance of the error, and of the causes.
  • Facilitate error logging.

Furthermore, in combination with the types of error Boom, errors for the REST-API interfaces, and Crash, standard application errors, it allows a complete management of the different types of errors in our backend.

Hierarchy (View Summary)

Constructors

  • Create a new Multi error

    Parameters

    • message: string

      human friendly error message

    Returns Multi

  • Create a new Multi error

    Parameters

    • message: string

      human friendly error message

    • options: MultiOptions

      enhanced error options

    Returns Multi

  • Create a new Multi error

    Parameters

    • message: string

      human friendly error message

    • uuid: string

      unique identifier for this particular occurrence of the problem

    Returns Multi

  • Create a new Multi error

    Parameters

    • message: string

      human friendly error message

    • uuid: string

      unique identifier for this particular occurrence of the problem

    • options: MultiOptions

      enhanced error options

    Returns Multi

Properties

date: Date

Error date

name: string = 'BaseError'

Error name (type)

subject: string

Error subject, 'common' as default

Accessors

  • get causes(): undefined | Cause[]
  • Causes 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 isMulti(): boolean
  • Determine if this instance is a Multi error

    Returns boolean

  • get size(): number
  • Return the number of causes of this error

    Returns number

  • 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/Multi 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

  • Process the errors thrown by Joi into the cause array

    Parameters

    Returns number

    number or error that have been introduced

  • Remove a error from the array of causes

    Returns undefined | Cause

    the cause that have been removed

  • Add a new error on the array of causes

    Parameters

    • error: Cause

      Cause to be added to the array of causes

    Returns void

  • Return a string formatted as name:message

    Returns string

  • Get the trace of this hierarchy of errors

    Returns string[]