🛡️TypeSafe 中文文档
原文档 ↗

Class: RateLimitError

HTTP 429:超出速率限制。

继承

构造函数

Constructor

ts
new RateLimitError(
   status, 
   body, 
   headers, 
   message?
): RateLimitError;

参数

status

number

body

unknown

headers

Headers

message?

string

返回值

RateLimitError

继承自

APIError.constructor

属性

body

ts
readonly body: unknown;

解析后的 JSON、响应文本,或响应体为空时的 undefined。

继承自

APIError.body


headers

ts
readonly headers: Headers;

HTTP 响应头。

继承自

APIError.headers


requestId

ts
readonly requestId: string | undefined;

来自 x-typesafe-request-id 的请求 ID,若不存在则为 undefined。

继承自

APIError.requestId


retryAfterMs

ts
readonly retryAfterMs: number | undefined;

服务器指示的重试延迟(毫秒),若不存在或无效则为 undefined。


status

ts
readonly status: number;

HTTP 响应状态码。

继承自

APIError.status

方法

fromResponse()

ts
static fromResponse(
   status, 
   body, 
   headers
): APIError;

为 HTTP 状态码创建对应的错误子类。

参数

status

number

body

unknown

headers

Headers

返回值

APIError

继承自

APIError.fromResponse

本站为 docs.typesafe.ai 的中文翻译,仅供学习参考;内容版权归原作者所有。