Skip to main content

Class: TokenExpiredError

Defined in: src/auth/errors.ts:67

Token expired error.

Remarks

Thrown when a JWT has expired. HTTP mapping: 401 Unauthorized

Extends

Constructors

new TokenExpiredError()

new TokenExpiredError(expiredAt): TokenExpiredError

Defined in: src/auth/errors.ts:78

Creates a new TokenExpiredError.

Parameters

expiredAt

Date

When the token expired

Returns

TokenExpiredError

Overrides

TokenValidationError.constructor

Properties

cause?

readonly optional cause: Error

Defined in: src/types/errors.ts:71

Original error that caused this error (if any).

Remarks

Error chaining allows tracking the full error context through multiple layers of the application. Useful for debugging complex error scenarios.

Example

try {
await fetchData();
} catch (err) {
throw new ValidationError('Failed to validate data', 'field', 'required', err as Error);
}

Inherited from

TokenValidationError.cause


code

readonly code: "TOKEN_VALIDATION_ERROR" = 'TOKEN_VALIDATION_ERROR'

Defined in: src/auth/errors.ts:38

Machine-readable error code.

Remarks

Error codes are unique identifiers for error types, enabling programmatic error handling (switch statements, error maps), error tracking in monitoring systems, and client-side error translation (i18n).

Inherited from

TokenValidationError.code


expiredAt

readonly expiredAt: Date

Defined in: src/auth/errors.ts:71

Token expiration timestamp.


tokenError

readonly tokenError: TokenErrorType

Defined in: src/auth/errors.ts:43

Specific token error type.

Inherited from

TokenValidationError.tokenError