Skip to main content

Class: AuthenticationError

Error thrown when authentication fails. Use for missing tokens, invalid credentials, or authorization failures.

Example

throw new AuthenticationError("User token is required");
throw new AuthenticationError("Failed to generate credentials", { cause: originalError });

Extends

Constructors

Constructor

new AuthenticationError(message: string, options?: {
cause?: Error;
context?: Record<string, unknown>;
}): AuthenticationError;

Parameters

ParameterType
messagestring
options?{ cause?: Error; context?: Record<string, unknown>; }
options.cause?Error
options.context?Record<string, unknown>

Returns

AuthenticationError

Inherited from

AppKitError.constructor

Properties

cause?

readonly optional cause: Error;

Optional cause of the error

Inherited from

AppKitError.cause


code

readonly code: "AUTHENTICATION_ERROR" = "AUTHENTICATION_ERROR";

Error code for programmatic error handling

Overrides

AppKitError.code


context?

readonly optional context: Record<string, unknown>;

Additional context for the error

Inherited from

AppKitError.context


isRetryable

readonly isRetryable: false = false;

Whether this error type is generally safe to retry

Overrides

AppKitError.isRetryable


statusCode

readonly statusCode: 401 = 401;

HTTP status code suggestion (can be overridden)

Overrides

AppKitError.statusCode

Methods

toJSON()

toJSON(): Record<string, unknown>;

Convert error to JSON for logging/serialization. Sensitive values in context are automatically redacted.

Returns

Record<string, unknown>

Inherited from

AppKitError.toJSON


toString()

toString(): string;

Create a human-readable string representation

Returns

string

Inherited from

AppKitError.toString


credentialsFailed()

static credentialsFailed(instance: string, cause?: Error): AuthenticationError;

Create an authentication error for credential generation failure

Parameters

ParameterType
instancestring
cause?Error

Returns

AuthenticationError


missingToken()

static missingToken(tokenType: string): AuthenticationError;

Create an authentication error for missing token

Parameters

ParameterTypeDefault value
tokenTypestring"access token"

Returns

AuthenticationError


missingUserId()

static missingUserId(): AuthenticationError;

Create an authentication error for missing user identity

Returns

AuthenticationError


userLookupFailed()

static userLookupFailed(cause?: Error): AuthenticationError;

Create an authentication error for failed user lookup

Parameters

ParameterType
cause?Error

Returns

AuthenticationError