Class: APIError
An unsuccessful (non-2xx) HTTP response from the API.
继承自
被以下类继承
BadRequestErrorAuthenticationErrorInsufficientBalanceErrorPermissionDeniedErrorNotFoundErrorUnprocessableEntityErrorRateLimitErrorOverloadedErrorInternalServerErrorAPIResponseValidationError
构造函数
构造函数
ts
new APIError(
status,
body,
headers,
message?,
options?
): APIError;参数
status
number
body
unknown
headers
Headers
message?
string
options?
ErrorOptions
返回
APIError
重写
属性
body
ts
readonly body: unknown;解析后的 JSON 错误体、纯文本,或空体时为 undefined。 / Parsed JSON, text, or undefined.
headers
ts
readonly headers: Headers;响应头。 / Response headers.
requestId
ts
readonly requestId: string | undefined;x-request-id 响应头,联系技术支持时请提供。 / The x-request-id header.
status
ts
readonly status: number;HTTP 状态码。 / HTTP status code.
访问器
detail
Getter 签名
ts
get detail(): unknown;错误体中的 detail 字段:字符串(如 "insufficient_balance")或校验错误列表;没有时为 undefined。
The detail field of the error body, or undefined.
返回
unknown
方法
fromResponse()
ts
static fromResponse(
status,
body,
headers
): APIError;按状态码创建对应的错误子类。 / Create the error subclass for an HTTP status.
参数
status
number
body
unknown
headers
Headers
返回
APIError

