@clerk/shared
Version:
Internal package utils used by the Clerk SDKs
40 lines (39 loc) • 1.32 kB
text/typescript
import { ClerkAPIResponseError } from "./clerkApiResponseError.mjs";
//#region src/errors/missingExpiredTokenError.d.ts
/**
* Error class representing a missing expired token error from the API.
* This error occurs when the server requires an expired token to mint a new session token.
*
* Use the static `is` method to check if a ClerkAPIResponseError matches this error type.
*
* @example
* ```typescript
* if (MissingExpiredTokenError.is(error)) {
* // Handle the missing expired token error
* }
* ```
*/
declare class MissingExpiredTokenError extends ClerkAPIResponseError {
static kind: string;
static readonly ERROR_CODE: "missing_expired_token";
static readonly STATUS: 422;
/**
* Type guard to check if an error is a MissingExpiredTokenError.
* This checks the error's properties (status and error code) rather than instanceof,
* allowing it to work with ClerkAPIResponseError instances thrown from the API layer.
*
* @example
* ```typescript
* try {
* await someApiCall();
* } catch (e) {
* if (MissingExpiredTokenError.is(e)) {
* // e is typed as ClerkAPIResponseError with the specific error properties
* }
* }
* ```
*/
static is(err: unknown): err is ClerkAPIResponseError;
}
//#endregion
export { MissingExpiredTokenError };