@zerokurns/unlayer-ts-client
Version:
TypeScript client library for the Unlayer Cloud API
22 lines (21 loc) • 939 B
TypeScript
import { AxiosError } from 'axios';
/** Custom Error class for Unlayer API errors */
export declare class UnlayerApiError extends Error {
readonly statusCode?: number;
readonly responseData?: unknown;
readonly requestData?: unknown;
readonly isUnlayerApiError = true;
constructor(message: string, statusCode?: number, responseData?: unknown, requestData?: unknown);
}
/**
* Type guard to check if an error is an instance of UnlayerApiError.
* @param error - The error to check.
* @returns True if the error is an UnlayerApiError, false otherwise.
*/
export declare function isUnlayerApiError(error: unknown): error is UnlayerApiError;
/**
* Parses AxiosError and throws a standardized UnlayerApiError.
* This function guarantees to throw, indicated by the `never` return type.
* @param error - The error caught from an Axios request.
*/
export declare function handleApiError(error: AxiosError | Error): never;