| 370 | * @since 4.0.0 |
| 371 | */ |
| 372 | export class RateLimitError extends Schema.Error<RateLimitError>( |
| 373 | "effect/ai/AiError/RateLimitError" |
| 374 | )({ |
| 375 | _tag: Schema.tag("RateLimitError"), |
| 376 | retryAfter: Schema.optional(Schema.Duration), |
| 377 | metadata: providerMetadataWithDefaults<RateLimitErrorMetadata>(), |
| 378 | http: Schema.optional(HttpContext) |
| 379 | }) { |
| 380 | /** |
| 381 | * Marks `RateLimitError` as a semantic AI error reason for runtime guards. |
| 382 | * |
| 383 | * @since 4.0.0 |
| 384 | */ |
| 385 | readonly [ReasonTypeId] = ReasonTypeId |
| 386 | |
| 387 | /** |
| 388 | * Rate limit errors are always retryable. |
| 389 | * |
| 390 | * @since 4.0.0 |
| 391 | */ |
| 392 | get isRetryable(): boolean { |
| 393 | return true |
| 394 | } |
| 395 | |
| 396 | override get message(): string { |
| 397 | let msg = "Rate limit exceeded" |
| 398 | if (this.retryAfter) msg += `. Retry after ${Duration.format(this.retryAfter)}` |
| 399 | return msg |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Error indicating account or billing limits have been reached. |
nothing calls this directly
no test coverage detected