import type { LylaAdapterMeta, LylaRequestOptionsWithContext, LylaRequestOptions, LylaResponse } from './types'; export declare enum LYLA_ERROR { /** * Request encountered an error, fired by XHR `onerror` event. It doesn't mean * your network has error, for example CORS error also triggers NETWORK_ERROR. */ NETWORK = "NETWORK", /** * Request is aborted. */ ABORTED = "ABORTED", /** * Response text is not valid JSON. */ INVALID_JSON = "INVALID_JSON", /** * Trying resolving `response.json` with `responseType='arraybuffer'` or * `responseType='blob'`. */ INVALID_CONVERSION = "INVALID_CONVERSION", /** * Request timeout. */ TIMEOUT = "TIMEOUT", /** * HTTP status error. */ HTTP = "HTTP", /** * Request `options` is not valid. It's not a response error. */ BAD_REQUEST = "BAD_REQUEST", /** * `onAfterResponse` hook throws error. */ BROKEN_ON_AFTER_RESPONSE = "BROKEN_ON_AFTER_RESPONSE", /** * `onBeforeRequest` hook throws error. */ BROKEN_ON_BEFORE_REQUEST = "BROKEN_ON_BEFORE_REQUEST", /** * `onInit` hook throws error. */ BROKEN_ON_INIT = "BROKEN_ON_INIT", /** * `onResponseError` hook throws error. */ BROKEN_ON_RESPONSE_ERROR = "BROKEN_ON_RESPONSE_ERROR", /** * `onNonResponseError` hook throws error. */ BROKEN_ON_NON_RESPONSE_ERROR = "BROKEN_ON_NON_RESPONSE_ERROR", /** * `onHeadersReceived` hook throws error. */ BROKEN_ON_HEADERS_RECEIVED = "BROKEN_ON_HEADERS_RECEIVED", /** * Lyla instance created with `withRetry` throws an unexpected error. This * error isn't created by `lyla` instance itself, but thrown by `onRejected` * or `onResolved` of `withRetry` or the process of creating retry request options * defined by user. * * The error won't be created by `lyla` instance that not created with `withRetry`. */ BROKEN_RETRY = "BROKEN_RETRY", /** * A non-lyla error is return by `onRejected` or `onResolved`'s `reject` action. * Lyla error won't be wrapped in this error. * * The error won't be created by `lyla` instance that not created with `withRetry`. */ RETRY_REJECTED_BY_NON_LYLA_ERROR = "RETRY_REJECTED_BY_NON_LYLA_ERROR" } export interface LylaBrokenOnHeadersReceivedError extends Error { type: LYLA_ERROR.BROKEN_ON_HEADERS_RECEIVED; error: unknown; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaBrokenOnAfterResponseError extends Error { type: LYLA_ERROR.BROKEN_ON_AFTER_RESPONSE; error: unknown; detail: undefined; response: LylaResponse; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaBrokenOnResponseErrorError extends Error { type: LYLA_ERROR.BROKEN_ON_RESPONSE_ERROR; error: unknown; detail: undefined; response: LylaResponse | undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaBrokenOnNonResponseErrorError extends Error { type: LYLA_ERROR.BROKEN_ON_NON_RESPONSE_ERROR; error: unknown; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaBrokenOnBeforeRequestError extends Error { type: LYLA_ERROR.BROKEN_ON_BEFORE_REQUEST; error: unknown; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaBrokenRetryError extends Error { type: LYLA_ERROR.BROKEN_RETRY; error: unknown; detail: undefined; response: undefined; context: C | undefined; requestOptions: LylaRequestOptions; isRetryError: true; spread: () => Omit, 'spread'>; } export interface LylaRetryRejectedByNonLylaErrorError extends Error { type: LYLA_ERROR.RETRY_REJECTED_BY_NON_LYLA_ERROR; error: unknown; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptions; isRetryError: true; spread: () => Omit, 'spread'>; } export interface LylaBrokenOnInitError extends Error { type: LYLA_ERROR.BROKEN_ON_INIT; error: unknown; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaTimeoutError extends Error { type: LYLA_ERROR.TIMEOUT; error: undefined; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaInvalidConversionError extends Error { type: LYLA_ERROR.INVALID_CONVERSION; error: undefined; detail: undefined; response: LylaResponse; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaHttpError extends Error { type: LYLA_ERROR.HTTP; error: undefined; detail: undefined; response: LylaResponse; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaNetworkError extends Error { type: LYLA_ERROR.NETWORK; error: undefined; detail: M['networkErrorDetail']; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaInvalidJSONError extends Error { type: LYLA_ERROR.INVALID_JSON; error: SyntaxError; detail: undefined; response: LylaResponse; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaAbortedError extends Error { type: LYLA_ERROR.ABORTED; error: undefined; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export interface LylaBadRequestError extends Error { type: LYLA_ERROR.BAD_REQUEST; error: undefined; detail: undefined; response: undefined; context: C; requestOptions: LylaRequestOptionsWithContext; spread: () => Omit, 'spread'>; } export type LylaDataConversionError = LylaInvalidJSONError | LylaInvalidConversionError; export type LylaResponseError = LylaNetworkError | LylaHttpError | LylaAbortedError | LylaTimeoutError; export type LylaNonResponseError = LylaAbortedError | LylaTimeoutError | LylaBadRequestError | LylaBrokenOnAfterResponseError | LylaBrokenOnResponseErrorError | LylaBrokenOnInitError | LylaBrokenOnBeforeRequestError | LylaBrokenOnHeadersReceivedError | LylaDataConversionError; export type LylaRetryError = LylaBrokenRetryError | LylaRetryRejectedByNonLylaErrorError; export type LylaError = LylaResponseError | LylaNonResponseError | LylaBrokenOnNonResponseErrorError; export type LylaErrorWithRetry = LylaError | LylaRetryError; export declare function defineLylaError | LylaRetryError>(lylaErrorProps: Omit, stack: string | undefined): T; export declare function isLylaError(error: unknown): error is LylaError; export declare function isLylaErrorWithRetry(error: unknown): error is LylaErrorWithRetry; //# sourceMappingURL=error.d.ts.map