# ovok_sdk.errors

Canonical page: https://docs.ovok.com/python-sdk/reference/errors

Errors the SDK raises, one class per kind of failure.

## FieldError [#fielderror]

```python
FieldError(
    message: str,
    path: tuple[str, ...] = (),
    code: str | None = None,
    validation: str | None = None,
)
```

One invalid part of a request, named by its path.

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `message` | `str` | What is wrong with the value. |
| `path` | `tuple[str, ...]` | Location of the value in the request body, such as `("name", "0")`. |
| `code` | `str \| None` | Machine-readable error code, when the API sends one. |
| `validation` | `str \| None` | Name of the failed validation rule, when the API sends one. |

## OvokErrorDetails [#ovokerrordetails]

```python
OvokErrorDetails(
    message: str,
    status: int | None = None,
    code: str | None = None,
    type: str | None = None,
    trace_id: str | None = None,
    request_id: str | None = None,
    retry_after_ms: int | None = None,
    field_errors: tuple[FieldError, ...] = (),
)
```

Everything known about one failure; the fields of an `OvokError`.

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `message` | `str` | Human-readable description. |
| `status` | `int \| None` | HTTP status, or None when no response arrived. |
| `code` | `str \| None` | Machine-readable error code from the response. |
| `type` | `str \| None` | Error type from the response. |
| `trace_id` | `str \| None` | Server trace ID; quote it when reporting the failure. |
| `request_id` | `str \| None` | Server request ID. |
| `retry_after_ms` | `int \| None` | How long to wait before retrying, from `Retry-After`. |
| `field_errors` | `tuple[FieldError, ...]` | Invalid parts of the request. |

## OvokError [#ovokerror]

```python
OvokError(details: OvokErrorDetails)
```

Bases: `Exception`

Every SDK failure; quote `trace_id` when reporting one.

Catch this class to handle any SDK error. Its attributes copy `OvokErrorDetails`.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `details` | `OvokErrorDetails` |  | Everything known about the failure. |

**Attributes**

| Name | Type | Description |
| --- | --- | --- |
| `message` |  | Human-readable description. |
| `status` |  | HTTP status, or None when no response arrived. |
| `code` |  | Machine-readable error code from the response. |
| `type` |  | Error type from the response. |
| `trace_id` |  | Server trace ID. |
| `request_id` |  | Server request ID. |
| `retry_after_ms` |  | How long to wait before retrying, from `Retry-After`. |
| `field_errors` |  | Invalid parts of the request. |

## OvokValidationError [#ovokvalidationerror]

```python
OvokValidationError()
```

Bases: `OvokError`

The request was malformed or failed validation (400, 422).

## OvokAuthenticationError [#ovokauthenticationerror]

```python
OvokAuthenticationError()
```

Bases: `OvokError`

Credentials are missing, invalid or expired (401).

## OvokPermissionError [#ovokpermissionerror]

```python
OvokPermissionError()
```

Bases: `OvokError`

The caller is signed in but not allowed to do this (403).

## OvokNotFoundError [#ovoknotfounderror]

```python
OvokNotFoundError()
```

Bases: `OvokError`

The resource does not exist (404).

## OvokConflictError [#ovokconflicterror]

```python
OvokConflictError()
```

Bases: `OvokError`

The request conflicts with the current state, such as a duplicate (409).

## OvokRateLimitError [#ovokratelimiterror]

```python
OvokRateLimitError()
```

Bases: `OvokError`

Too many requests (429); wait `retry_after_ms` before retrying.

## OvokServiceError [#ovokserviceerror]

```python
OvokServiceError()
```

Bases: `OvokError`

The server failed or was unavailable (5xx).

## OvokConnectionError [#ovokconnectionerror]

```python
OvokConnectionError()
```

Bases: `OvokError`

No response arrived: the connection failed or timed out.

## OvokConfigError [#ovokconfigerror]

```python
OvokConfigError()
```

Bases: `OvokError`

A client option is invalid; raised when the client is constructed.

## error_for_status() [#error_for_status]

```python
error_for_status(details: OvokErrorDetails) -> OvokError
```

Build the `OvokError` subclass that matches `details.status`.

**Parameters**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `details` | `OvokErrorDetails` |  | The failure, with its HTTP status. |

**Returns**

- `OvokError`: `OvokServiceError` for 5xx, a status-specific class where one exists, else `OvokError`.
