guardz-axios
Version:
Type-safe HTTP client built on top of Axios with runtime validation using guardz. Part of the guardz ecosystem for comprehensive TypeScript type safety.
104 lines • 2.94 kB
TypeScript
import { TypeGuardFn } from "guardz";
import { AxiosError, AxiosResponse } from "axios";
import { NetworkError, TimeoutError, CancelError, ResponseError, ClientErrorStatus, ServerErrorStatus } from "../types/axios-types";
/**
* Type guard for basic AxiosError structure
*/
export declare const isAxiosError: TypeGuardFn<AxiosError>;
/**
* Type guard for AxiosError with response (4xx/5xx errors)
*/
export declare const isAxiosErrorWithResponse: TypeGuardFn<ResponseError>;
/**
* Type guard for network errors (no response received)
*/
export declare const isNetworkError: TypeGuardFn<NetworkError>;
/**
* Type guard for timeout errors
*/
export declare const isTimeoutError: TypeGuardFn<TimeoutError>;
/**
* Type guard for cancel errors
*/
export declare const isCancelError: TypeGuardFn<CancelError>;
/**
* Type guard for client errors (4xx status codes)
*/
export declare const isClientError: TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: ClientErrorStatus;
};
}>;
/**
* Type guard for server errors (5xx status codes)
*/
export declare const isServerError: TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: ServerErrorStatus;
};
}>;
/**
* Type guard for authentication errors (401 Unauthorized)
*/
export declare const isAuthenticationError: TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: 401;
};
}>;
/**
* Type guard for authorization errors (403 Forbidden)
*/
export declare const isAuthorizationError: TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: 403;
};
}>;
/**
* Type guard for not found errors (404 Not Found)
*/
export declare const isNotFoundError: TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: 404;
};
}>;
/**
* Type guard for validation errors (422 Unprocessable Entity)
*/
export declare const isValidationError: TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: 422;
};
}>;
/**
* Type guard for rate limit errors (429 Too Many Requests)
*/
export declare const isRateLimitError: TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: 429;
};
}>;
/**
* Type guard for specific error status code
*/
export declare function isErrorWithStatus<T extends number>(statusCode: T): TypeGuardFn<AxiosError & {
response: AxiosResponse & {
status: T;
};
}>;
/**
* Type guard for specific error code
*/
export declare function isErrorWithCode<T extends string>(errorCode: T): TypeGuardFn<AxiosError & {
code: T;
}>;
/**
* Comprehensive error categorization function
*/
export declare function categorizeAxiosError(error: unknown): {
isAxiosError: boolean;
category: "network" | "timeout" | "cancel" | "client" | "server" | "unknown";
statusCode?: number;
errorCode?: string;
hasResponse: boolean;
};
//# sourceMappingURL=axios-error-guards.d.ts.map