Class InternalServerError

Represents a generic server error, by default a 500 Internal Server Error.

This class extends the abstract ServiceError class and is used to handle generic internal server-side errors. It can also be extended to define more specific server-side error classes (e.g. Server is down for maintenance).

The InternalServerError class provides a default implementation for the serializeErrors method, which returns a generic internal server error response.

InternalServerError

Hierarchy (view full)

Constructors

Properties

code: number = 500

The HTTP status code for the error. In this case, 500 represents an internal server error.

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

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Serializes the error details into an array of BaseServiceError objects.

    This method is responsible for transforming the error into a user-friendly format that can be returned to the client or used in API responses. The default implementation returns a generic 500 error response.

    Returns BaseServiceError[]

    An array containing a single BaseServiceError object with:

    • code: The HTTP status code (500).
    • type: The error type ("InternalServerError").
    • message: A user-friendly message indicating that something went wrong internally.
  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void