Skip to content

Commit a095c24

Browse files
authored
Merge pull request #198 from flashcatcloud/doc-review/20260722-031640
docs(go-sdk): clarify intermediary error handling
2 parents 505616f + b6517a5 commit a095c24

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

en/developer/go-sdk.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,14 @@ for page := 0; page < 100; page++ {
249249

250250
---
251251

252-
Any unsuccessful call — whether the envelope carries an error or the HTTP status is non-2xx — returns `*ErrorResponse`. It has `Code`, `Message`, and `RequestID` fields; when troubleshooting, give `RequestID` to the support team to pinpoint the request.
252+
An unsuccessful call returned by the Flashduty API — whether the envelope carries an error or the HTTP status is non-2xx — returns `*ErrorResponse`. It has `Code`, `Message`, and `RequestID` fields; when troubleshooting, give `RequestID` to the support team to pinpoint the request.
253253

254254
When the API returns 429, the error is promoted to `*RateLimitError`: it embeds `*ErrorResponse` (so `errors.As` for `*ErrorResponse` still matches) and additionally carries a `RetryAfter` hint.
255255

256+
<Note>
257+
If you receive a non-2xx response with a non-JSON body, the SDK returns a plain `error`, not `*ErrorResponse`. This indicates that a gateway, load balancer, proxy, or other intermediary produced the response, usually because the request exceeded an intermediary timeout. Retry the request or split a long-running batch into smaller batches, and do not assume that `errors.As(err, &apiErr)` matches this error.
258+
</Note>
259+
256260
```go
257261
_, _, err := client.Incidents.Info(ctx, &flashduty.IncidentInfoRequest{
258262
IncidentID: "does-not-exist",

zh/developer/go-sdk.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,14 @@ for page := 0; page < 100; page++ {
249249

250250
---
251251

252-
任何未成功的调用——无论是信封中携带了错误,还是 HTTP 状态非 2xx——都会返回 `*ErrorResponse`。它带有 `Code``Message``RequestID` 字段,排障时把 `RequestID` 提供给支持团队即可定位。
252+
Flashduty API 返回的未成功调用——无论是信封中携带了错误,还是 HTTP 状态非 2xx——都会返回 `*ErrorResponse`。它带有 `Code``Message``RequestID` 字段,排障时把 `RequestID` 提供给支持团队即可定位。
253253

254254
当 API 返回 429 时,错误被提升为 `*RateLimitError`:它内嵌 `*ErrorResponse`(所以 `errors.As``*ErrorResponse` 仍然成立),并额外带上 `RetryAfter` 提示。
255255

256+
<Note>
257+
如果你收到的是带非 JSON 响应体的非 2xx 响应,SDK 会返回普通 `error`,而不是 `*ErrorResponse`。这表示响应来自网关、负载均衡器或代理等中间层,通常是请求超过了中间层超时。你可以重试请求,或将耗时较长的批量请求拆分为更小的批次;不要假定 `errors.As(err, &apiErr)` 能匹配此类错误。
258+
</Note>
259+
256260
```go
257261
_, _, err := client.Incidents.Info(ctx, &flashduty.IncidentInfoRequest{
258262
IncidentID: "does-not-exist",

0 commit comments

Comments
 (0)