UNPKG

@datocms/rest-client-utils

Version:
47 lines (46 loc) 1.28 kB
export type ErrorEntity = { id: string; type: 'api_error'; attributes: { code: string; transient?: true; doc_url: string; details: Record<string, unknown>; }; }; type FilterFn = (details: Record<string, unknown>) => boolean; export type ApiErrorRequest = { url: string; method: string; headers: Record<string, string>; body?: unknown; }; export type ApiErrorResponse = { status: number; statusText: string; headers: Record<string, string>; body?: unknown; }; export type TimeoutErrorInitObject = { request: ApiErrorRequest; preCallStack?: string; }; export declare class TimeoutError extends Error { request: ApiErrorRequest; preCallStack?: string; constructor(initObject: TimeoutErrorInitObject); } export type ApiErrorInitObject = { request: ApiErrorRequest; response: ApiErrorResponse; preCallStack?: string; }; export declare class ApiError extends Error { request: ApiErrorRequest; response: ApiErrorResponse; preCallStack?: string; constructor(initObject: ApiErrorInitObject); get errors(): ErrorEntity[]; findError(codeOrCodes: string | string[], filterDetails?: Record<string, string> | FilterFn): ErrorEntity | undefined; } export {};