UNPKG

@commercelayer/sdk

Version:
39 lines (36 loc) 1.24 kB
declare enum ErrorType { CLIENT = "client",// Generic Client error REQUEST = "request",// Error preparing API request RESPONSE = "response",// Error response from API CANCEL = "cancel",// Forced request abort using interceptor PARSE = "parse",// Error parsing API resource TIMEOUT = "timeout",// Timeout error TOKEN_REFRESH = "token-refresh" } declare class SdkError extends Error { static NAME: string; static isSdkError(error: any): error is SdkError; type: ErrorType; code?: string; source?: Error; constructor(error: { message: string; type?: ErrorType; }); } declare class ApiError extends SdkError { static NAME: string; static isApiError(error: any): error is ApiError; errors: any[]; status?: number; statusText?: string; constructor(error: { message: string; }); first(): any; } declare const isExpiredTokenError: (error: any) => boolean; declare const handleError: (error: Error) => never; declare function isSdkError(error: unknown): error is SdkError; declare function isApiError(error: unknown): error is ApiError; export { ApiError, ErrorType, SdkError, handleError, isApiError, isExpiredTokenError, isSdkError };