UNPKG

@anthropic-ai/sdk

Version:
111 lines • 4.36 kB
import type * as Shared from "../resources/shared.mjs"; export declare class AnthropicError extends Error { } export declare class APIError<TStatus extends number | undefined = number | undefined, THeaders extends Headers | undefined = Headers | undefined, TError extends Object | undefined = Object | undefined> extends AnthropicError { /** HTTP status for the response that caused the error */ readonly status: TStatus; /** HTTP headers for the response that caused the error */ readonly headers: THeaders; /** JSON body of the response that caused the error */ readonly error: TError; readonly requestID: string | null | undefined; readonly workspaceID: string | null | undefined; /** * A human-readable explanation of the error. Its wording can change, so don't * match on it. * * `error.message` from the response body, if present. */ readonly apiMessage: string | null; /** * The broad category of the error. * * `error.type` from the response body, if present. */ readonly type: Shared.ErrorType | null; /** * A stable code that names the cause. * * `error.details.error_code` from the response body, if present and a string. */ readonly errorCode: string | null; /** * Machine-readable detail about the cause of the error. `error_code` names the * cause; branch on it rather than on `message`. Absent when the error has no code. * Treat an unrecognized `error_code` as the bare `type`. * * `error.details` from the response body, if present. */ readonly details: Shared.ErrorDetails | null; constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders, type?: Shared.ErrorType | null); private static makeMessage; static generate(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined): APIError; } export declare class APIUserAbortError extends APIError<undefined, undefined, undefined> { constructor({ message }?: { message?: string; }); } export declare class APIConnectionError extends APIError<undefined, undefined, undefined> { constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined; }); } export declare class APIConnectionTimeoutError extends APIConnectionError { constructor({ message }?: { message?: string; }); } /** * An error that opts into the SDK's retry policy: throw it (e.g. from * middleware) to have the attempt retried. * * Note that the request will only be retried when `maxRetries` has not been exhausted. */ export declare class RetryableError extends AnthropicError { constructor(message?: string, { cause }?: { cause?: unknown; }); } export declare class BadRequestError extends APIError<400, Headers> { } export declare class AuthenticationError extends APIError<401, Headers> { } export declare class PaymentRequiredError extends APIError<402, Headers> { } export declare class PermissionDeniedError extends APIError<403, Headers> { } export declare class NotFoundError extends APIError<404, Headers> { } export declare class RequestTimeoutError extends APIError<408, Headers> { } export declare class ConflictError extends APIError<409, Headers> { } export declare class PreconditionFailedError extends APIError<412, Headers> { } export declare class ContentTooLargeError extends APIError<413, Headers> { } export declare class UnprocessableEntityError extends APIError<422, Headers> { } export declare class RateLimitError extends APIError<429, Headers> { } export declare class RequestHeaderFieldsTooLargeError extends APIError<431, Headers> { } export declare class ClientClosedRequestError extends APIError<499, Headers> { } export declare class InternalServerError extends APIError<number, Headers> { } export declare class NotImplementedError extends InternalServerError { readonly status: 501; } export declare class ServiceUnavailableError extends InternalServerError { readonly status: 503; } export declare class GatewayTimeoutError extends InternalServerError { readonly status: 504; } export declare class OverloadedError extends InternalServerError { readonly status: 529; } //# sourceMappingURL=error.d.mts.map