来自 API 的不成功 HTTP 响应。
继承
派生
AuthenticationErrorBadRequestErrorInternalServerErrorNotFoundErrorPermissionDeniedErrorRateLimitErrorUnprocessableEntityError
构造函数
构造函数
ts
new APIError(
status,
body,
headers,
message?
): APIError;
参数
status
number
body
unknown
headers
Headers
message?
string
返回值
APIError
重写
属性
body
ts
readonly body: unknown;
解析后的 JSON、响应文本,若响应体为空则为 undefined。
headers
ts
readonly headers: Headers;
HTTP 响应头。
requestId
ts
readonly requestId: string | undefined;
来自 x-typesafe-request-id 的请求 ID,不存在时为 undefined。
status
ts
readonly status: number;
HTTP 响应状态码。
方法
fromResponse()
ts
static fromResponse(
status,
body,
headers
): APIError;
根据 HTTP 状态码创建对应的错误子类。
参数
status
number
body
unknown
headers
Headers
返回值
APIError