Class ControllerError

Custom error class to standardize error handling in controllers. Includes a unique key, detailed message, and associated HTTP status code.

Hierarchy

  • Error
    • ControllerError

Constructors

  • Constructor for the ControllerError class.

    Parameters

    • key: string

      A unique key identifying the error.

    • Optionalmessage: string

      An optional detailed message for the error. If not provided, a default message is generated using the key.

    • httpStatus: number = 400

      The HTTP status code for the error (default is 400 - Bad Request).

    Returns ControllerError

Properties

httpStatus: number
key: string
message: string
name: string
stack?: string
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void