# `AshScylla.Error`
[🔗](https://github.com/ohhi-vn/ash_scylla/blob/main/lib/ash_scylla/error.ex#L15)

Common error types and utilities for AshScylla.

This module provides a unified interface for error handling across the AshScylla
library, including ScyllaDB-specific errors, configuration errors, and query errors.

## Functions

- `wrap_xandra_error/1` — Convert Xandra errors to `ScyllaError`
- `format_error/1` — Format any error for display
- `retryable?/1` — Check if an error is retryable

See `AshScylla.Error.ScyllaError` for the structured error type with
categorization and suggestions.

# `format_error`

```elixir
@spec format_error(AshScylla.Error.ScyllaError.t()) :: String.t()
@spec format_error(term()) :: String.t()
```

Formats an error for display to the user.

# `retryable?`

```elixir
@spec retryable?(AshScylla.Error.ScyllaError.t() | term()) :: boolean()
```

Checks if an error is retryable.

Public utility intended for callers implementing their own retry policy.
Returns `true` for transient ScyllaDB errors such as timeouts, connection
failures, and overloaded nodes — cases where retrying the same operation
may succeed. Returns `false` for all other errors, including unknown types.

## Retryable error types

- `:connection_timeout`
- `:connection_closed`
- `:overloaded`
- `:timeout`
- `:connection_error`

## Examples

    iex> error = %AshScylla.Error.ScyllaError{type: :timeout, message: "timeout"}
    iex> AshScylla.Error.retryable?(error)
    true

    iex> error = %AshScylla.Error.ScyllaError{type: :invalid, message: "bad query"}
    iex> AshScylla.Error.retryable?(error)
    false

# `wrap_xandra_error`

```elixir
@spec wrap_xandra_error(Xandra.Error.t()) :: AshScylla.Error.ScyllaError.t()
@spec wrap_xandra_error(Xandra.ConnectionError.t()) :: AshScylla.Error.ScyllaError.t()
@spec wrap_xandra_error(term()) :: AshScylla.Error.ScyllaError.t()
```

Wraps a Xandra error into a structured AshScylla error.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
