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 (View Summary)

Constructors

  • 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

    • Optionaloptions: BoomOptions

      enhanced error options

    Returns Boom

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 isBoom(): boolean
  • Boom error

    Returns boolean

  • 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 | Links

  • get resource(): undefined | APISource
  • Object with the key information of the requested resource in the REST API context

    Returns undefined | APISource

  • get source(): undefined | APISource
  • Object with the key information of the requested resource in the REST API context

    Returns undefined | APISource

    • source has been deprecated, use resource instead
  • get status(): number
  • Boom error code

    Returns number

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

    Returns string

Methods

  • Transform joi Validation error in a Boom error

    Parameters

    Returns void

  • Return a string formatted as name:message

    Returns string

  • Get the trace of this hierarchy of errors

    Returns string[]