japanpost-api
Version:
Japan Post Servive API client
86 lines • 2.2 kB
TypeScript
export interface JapanPostAPIErrorOptions {
status: number;
body: string;
headers: Record<string, string>;
}
/**
* Base class for Japan Post API related errors
*/
export declare abstract class JapanPostAPIError extends Error {
status: number;
headers: Record<string, string>;
body: string;
error: JapanPostAPIErrorBody | null;
constructor({ status, body, headers }: JapanPostAPIErrorOptions, message?: string);
/**
* Create appropriate error class instance from error response
*/
static createFromResponse(options: JapanPostAPIErrorOptions): JapanPostAPIError;
}
/**
* Authentication error (401 Unauthorized)
*/
export declare class AuthenticationError extends JapanPostAPIError {
constructor(options: JapanPostAPIErrorOptions);
}
/**
* Authorization error (403 Forbidden)
*/
export declare class AuthorizationError extends JapanPostAPIError {
constructor(options: JapanPostAPIErrorOptions);
}
/**
* Rate limit error (429 Too Many Requests)
*/
export declare class RateLimitError extends JapanPostAPIError {
retryAfter?: number;
constructor(options: JapanPostAPIErrorOptions);
}
/**
* Client error (4xx series)
*/
export declare class ClientError extends JapanPostAPIError {
constructor(options: JapanPostAPIErrorOptions);
}
/**
* Server error (5xx series)
*/
export declare class ServerError extends JapanPostAPIError {
constructor(options: JapanPostAPIErrorOptions);
}
/**
* Network error
*/
export declare class NetworkError extends Error {
originalError: Error;
constructor(originalError: Error);
}
/**
* General API error
*/
export declare class GeneralAPIError extends JapanPostAPIError {
constructor(options: JapanPostAPIErrorOptions);
}
/**
* Validation error
*/
export declare class ValidationError extends Error {
field: string;
value: any;
constructor(field: string, value: any, message: string);
}
export type JapanPostAPIErrorBody = {
/**
* Request ID (tracking code)
*/
request_id: string;
/**
* Error code
*/
error_code: string;
/**
* Error message
*/
message: string;
};
//# sourceMappingURL=JapanPostAPIError.d.ts.map