# rok-error

Unified error type for the rok ecosystem.

`RokError` merges ORM, auth, and validation errors into one `IntoResponse`-compatible type so handler return types become simple `Result<T, RokError>`.

## Install

```toml
rok-error = { version = "0.1", features = ["axum"] }
```

## Usage

```rust
use rok_error::RokError;
use rok_orm::PgModel;
use axum::{Json, extract::Path};

async fn get_user(Path(id): Path<i64>) -> Result<Json<User>, RokError> {
    let pool = rok_orm::pool::current_pool();
    let user = User::find_or_fail(&pool, id).await?; // RowNotFound → 404
    Ok(Json(user))
}
```

## Error → HTTP status mapping

| Variant | Status |
|---|---|
| `NotFound` | 404 |
| `Forbidden` | 403 |
| `Validation(_)` | 422 |
| `Auth(InvalidToken \| TokenExpired \| InvalidCredentials)` | 401 |
| `Auth(Forbidden(_))` | 403 |
| `Orm(_) \| Internal(_)` | 500 |

## Features

| Feature | Description |
|---|---|
| `axum` | Enable `IntoResponse` for `RokError` |
