AshScylla.Error.ScyllaError (AshScylla v0.2.0)

Copy Markdown View Source

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

Summary

Functions

Creates a ScyllaError from a generic error.

Creates a ScyllaError from a Xandra.ConnectionError.

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

Creates a ScyllaError from a Xandra.Error.

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

Converts the error to a human-readable string.

Creates a ScyllaError with query context.

Types

t()

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

Functions

from_error(error)

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

Creates a ScyllaError from a generic error.

from_xandra_connection_error(error)

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

Creates a ScyllaError from a Xandra.ConnectionError.

from_xandra_connection_error(error, query)

@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(error)

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

Creates a ScyllaError from a Xandra.Error.

from_xandra_error(error, query)

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

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

to_string(error)

@spec to_string(t()) :: String.t()

Converts the error to a human-readable string.

with_query(error, query)

@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.