/** * Typed errors for every way a ThriveCart call can fail. * * ThriveCart returns plain HTTP statuses with a thin body, so the status is * most of the signal and the message has to supply the rest. A bare * "ThriveCart API error 401" tells a model nothing it can act on; naming the * likely cause (wrong host, account key instead of API key, a cart the key * does not cover) is the difference between a correct retry and a give-up. */ export declare class ThriveCartError extends Error { readonly status: number; readonly endpoint: string; /** The account whose key was used, so a multi-cart failure names the cart. */ readonly account: string; readonly detail: string; constructor(message: string, status: number, endpoint: string, account?: string, detail?: string); toJSON(): Record; } /** 401/403. The key is wrong, revoked, or belongs to a different cart. */ export declare class AuthenticationError extends ThriveCartError { } /** 400. The arguments were rejected. */ export declare class ValidationError extends ThriveCartError { } /** 404. No such product, order, customer or affiliate. */ export declare class NotFoundError extends ThriveCartError { } /** 429. Backed off and retried already; this is after the last attempt. */ export declare class RateLimitError extends ThriveCartError { readonly retryAfter?: number; constructor(message: string, status: number, endpoint: string, account: string, detail: string, retryAfter?: number); toJSON(): Record; } /** 5xx. Upstream, usually transient. */ export declare class ServerError extends ThriveCartError { } /** Synthetic 408. Nothing arrived before our own deadline. */ export declare class TimeoutError extends ThriveCartError { } /** Writes are disabled, or a destructive tool was called without `confirm`. */ export declare class WriteBlockedError extends ThriveCartError { constructor(message: string); } /** * Reduce a response body to something worth showing. * * Capped at 500 characters so an HTML error page from a proxy in front of * ThriveCart does not become the entire error message. */ export declare function parseErrorBody(body: string): string; /** Map a status onto the right class, with a message that names the fix. */ export declare function errorFor(status: number, endpoint: string, account: string, body: string, headers?: Headers): ThriveCartError;