Class UnauthorizedError

Represents an unauthorized access error, typically indicating that the user is not authenticated and needs to log in to access the requested resource.

This class extends the ClientError class and is used to handle HTTP 401 Unauthorized errors.

UnauthorizedError

Hierarchy (view full)

Constructors

Properties

code: number = 401

The HTTP status code representing unauthorized access.

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 returns the error details specific to unauthorized access, including the status code, type of error, and a user-friendly message.

    Returns BaseServiceError[]

    An array of serialized error details, which includes:

    • code: 401 (Unauthorized)
    • type: "UnauthorizedError" (the name of the error class)
    • message: A user-friendly message indicating that the user is not authenticated.
  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void