import {
APIError,
AuthenticationError,
NotFoundError,
RateLimitError,
ValidationError,
} from '@verial-ai/sdk'
try {
await verial.environments.get({ id: 'env_does_not_exist' })
} catch (err) {
if (err instanceof NotFoundError) {
// 404 — resource does not exist
} else if (err instanceof AuthenticationError) {
// 401 — bad API key
} else if (err instanceof RateLimitError) {
await sleep((err.retryAfter ?? 1) * 1000)
} else if (err instanceof ValidationError) {
console.error('validation', err.errors)
} else if (err instanceof APIError) {
// any other 4xx/5xx
console.error(err.status, err.code, err.requestId)
} else {
throw err
}
}