Options
All
  • Public
  • Public/Protected
  • All
Menu

Improved error handling in REST-API interfaces

Boom helps us with error responses (HTTP Codes 3XX-5XX) within our REST-API interface by providing us with some tools:

  • Helpers for the rapid generation of standard responses.
  • Association of errors and their causes in a hierarchical way.
  • Adaptation of validation errors of the Joi library.

In addition, in combination with the Multi error types, errors in validation processes, and Crash, standard application errors, it allows a complete management of the different types of errors in our backend.

Hierarchy

  • Base
    • Boom

Index

Constructors

constructor

  • new Boom(message: string, uuid: string, code?: number, options?: BoomOptions): Boom
  • Create a new Boom error

    Parameters

    • message: string

      human friendly error message

    • uuid: string

      unique identifier for this particular occurrence of the problem

    • code: number = 500

      HTTP Standard error code

    • Optional options: BoomOptions

      enhanced error options

    Returns Boom

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>

isBoom

  • get isBoom(): boolean
  • Boom error

    Returns boolean

links

  • get links(): undefined | {}
  • Links that leads to further details about this particular occurrence of the problem. A link MUST be represented as either:

    • self: a string containing the link’s URL
    • related: an object (“link object”) which can contain the following members:
      • href: a string containing the link’s URL.
      • meta: a meta object containing non-standard meta-information about the link.

    Returns undefined | {}

resource

  • Object with the key information of the requested resource in the REST API context

    Returns undefined | APISource

source

  • Object with the key information of the requested resource in the REST API context

    deprecated
    • source has been deprecated, use resource instead

    Returns undefined | APISource

status

  • get status(): number
  • Boom error code

    Returns number

uuid

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

    Returns string

Methods

Boomify

  • Transform joi Validation error in a Boom error

    Parameters

    Returns void

toJSON

  • Return APIError in JSON format

    Returns APIError

toString

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

    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