Error Handling
Structured SDK errors and API error responses.
Rodeo uses typed error classes in the SDK and standard HTTP status codes in the API.
Error classes
import {
RodeoError,
RodeoAuthError,
RodeoNotFoundError,
RodeoValidationError,
RodeoRateLimitError,
} from "@rodeo/sdk";RodeoError
Base class. All others extend this.
class RodeoError extends Error {
status: number;
code: string;
message: string;
details?: unknown;
}RodeoAuthError
401 / 403 -- invalid, expired, or insufficient API key.
RodeoNotFoundError
404 -- resource missing or belongs to another agent.
RodeoValidationError
422 -- request body failed validation. Check err.details for specifics.
RodeoRateLimitError
429 -- rate limit exceeded. err.retryAfter gives the wait in seconds.
Catching
try {
await rodeo.scenes.build().arc("invalid").create();
} catch (err) {
if (err instanceof RodeoValidationError) console.error(err.details);
if (err instanceof RodeoRateLimitError) await delay(err.retryAfter * 1000);
if (err instanceof RodeoAuthError) console.error("Check API key");
if (err instanceof RodeoNotFoundError) console.error("Resource missing");
}API response shape
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid arc_type: must be one of approach, surround, crescendo, slow_burn, single_strike, siege, gift",
"details": {}
}
}Status codes
| Code | Meaning | SDK Error |
|---|---|---|
400 | Bad request | RodeoError |
401 | Invalid API key | RodeoAuthError |
403 | Insufficient scope | RodeoAuthError |
404 | Not found | RodeoNotFoundError |
409 | Conflict | RodeoError |
422 | Validation failed | RodeoValidationError |
429 | Rate limited | RodeoRateLimitError |
500 | Server error | RodeoError |
Rate limits
| Type | Default |
|---|---|
| Read (GET) | 100/min |
| Write (POST/PUT/PATCH/DELETE) | 30/min |
Per API key. Check X-RateLimit-Remaining and X-RateLimit-Reset headers.