Creates an instance of UnauthorizedError
.
This constructor initializes the error with a log message for internal logging.
The HTTP status code representing unauthorized access.
Optional
stackStatic
Optional
prepareOptional override for formatting stack traces
Static
stackSerializes 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.
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.Converts the error object into a standardized JSON structure.
errors
with the serialized errors.Static
capture
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