# Errors

Methods return `{ data, error }`. Check error or use `throwOnError: true`.

## Check error

```ts
const { data, error } = await client.agent.get({ path: { id } })

if (error) {
  console.error(error.code, error.message)
  return
}

use(data)
```

## Throw on error

```ts
try {
  const { data } = await client.agent.get({
    path: { id },
    throwOnError: true,
  })
  use(data)
} catch (err) {
  // err is the typed error body
}
```

## Status codes

| Code | Meaning                     |
| ---- | --------------------------- |
| 400  | Validation error            |
| 401  | Missing or invalid PAT      |
| 403  | PAT valid but lacks scope   |
| 404  | Resource not found          |
| 409  | Conflict (e.g., name taken) |
| 429  | Rate limited                |
| 5xx  | Server error                |

## Related

- **[Client](/sdk/client)** — configuration.
- **[API reference](/api-reference)** — endpoint details.