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

Comprehensive error handling for ScyllaDB-specific errors.

This module provides structured error types for ScyllaDB/Cassandra errors,
user-friendly error messages, and suggestions for resolving common issues.

## Error Categories

- **Connection Errors**: Issues connecting to ScyllaDB nodes
- **Query Errors**: Invalid CQL syntax, type mismatches
- **Consistency Errors**: Write/read consistency failures
- **Schema Errors**: Table, keyspace, or column not found
- **Rate Limiting**: Overloaded nodes, timeout errors
- **Configuration Errors**: Invalid configuration options

## Usage

    case repo.query(query, params) do
      {:ok, result} ->
        {:ok, result}

      {:error, %Xandra.Error{} = error} ->
        {:error, AshScylla.Error.ScyllaError.from_xandra_error(error)}

      {:error, %Xandra.ConnectionError{} = error} ->
        {:error, AshScylla.Error.ScyllaError.from_xandra_connection_error(error)}
    end

# `t`

```elixir
@type t() :: %AshScylla.Error.ScyllaError{
  message: String.t(),
  original_error: term(),
  query: String.t() | nil,
  reason: term(),
  suggestion: String.t() | nil,
  type: atom()
}
```

# `from_error`

```elixir
@spec from_error(term()) :: t()
```

Creates a ScyllaError from a generic error.

# `from_xandra_connection_error`

```elixir
@spec from_xandra_connection_error(Xandra.ConnectionError.t()) :: t()
```

Creates a ScyllaError from a Xandra.ConnectionError.

# `from_xandra_connection_error`

```elixir
@spec from_xandra_connection_error(Xandra.ConnectionError.t(), String.t() | nil) ::
  t()
```

Creates a ScyllaError from a Xandra.ConnectionError with query context.

# `from_xandra_error`

```elixir
@spec from_xandra_error(Xandra.Error.t()) :: t()
```

Creates a ScyllaError from a Xandra.Error.

# `from_xandra_error`

```elixir
@spec from_xandra_error(Xandra.Error.t(), String.t() | nil) :: t()
```

Creates a ScyllaError from a Xandra.Error with query context.

# `to_string`

```elixir
@spec to_string(
  t(),
  keyword()
) :: String.t()
```

Converts the error to a human-readable string.

## Options
  * `:include_query` — Include the CQL query in the output (default: `false`)

# `with_query`

```elixir
@spec with_query(t(), String.t()) :: t()
```

Creates a ScyllaError with query context.

Convenience function for wrapping an error that includes the query
that caused it.

---

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