SDK
SDK: error handling
Every error is a subclass of AistAgentError. HTTP errors carry .status and .body, so you can catch specific situations by type.
Hierarchy
The base class is AistAgentError. HTTP errors are AistAgentApiError (with the
.status and .body properties) and its subclasses:
| Class | Status / case |
|---|---|
UnauthorizedError | 401 — the token is invalid, expired or revoked |
ForbiddenError | 403 — accessing someone else’s task |
NotFoundError | 404 — task not found |
TaskConflictError | 409 — tool-results for a task that isn’t interrupted |
ValidationError | 422 — the body failed validation |
RateLimitError | 429 — the active task limit is exceeded |
AistAgentTimeoutError | A request or wait timeout |
MissingToolHandlerError | No handler for the called client tool |
Example
ts
import { RateLimitError, ValidationError } from '@aist-packages/aist-agent-sdk'; try { await client.createTask({ assistant_id: 1, input: [textInput('…')] }); } catch (e) { if (e instanceof RateLimitError) { // 429: too many active tasks console.warn('Try again later:', e.status, e.body); } else if (e instanceof ValidationError) { // 422 console.error('Check the request body:', e.body); } else { throw e; } }
AistAgentApiError properties
| Property | Description |
|---|---|
.status | The HTTP response code. |
.body | The parsed response body (JSON or text). |
.message | A human-readable message. |
Error codes and what they mean on the server side are on the
Errors and limits page.