Options
All
  • Public
  • Public/Protected
  • All
Menu

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

  • Base
    • Multi

Index

Constructors

constructor

  • 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

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

causes

  • get causes(): undefined | Cause[]
  • Causes 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>

isMulti

  • get isMulti(): boolean
  • Determine if this instance is a Multi error

    Returns boolean

size

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

    Returns number

uuid

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

    Returns string

Methods

Multify

  • Process the errors thrown by Joi into the cause array

    Parameters

    Returns number

    number or error that have been introduced

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

pop

  • Remove a error from the array of causes

    Returns undefined | Cause

    the cause that have been removed

push

  • Add a new error on the array of causes

    Parameters

    • error: Cause

      Cause to be added to the array of causes

    Returns void

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