Packages
xandra
0.18.0-rc.7
0.19.4
0.19.3
0.19.2
0.19.1
0.19.0
0.18.1
0.18.0
0.18.0-rc.9
0.18.0-rc.8
0.18.0-rc.7
0.18.0-rc.6
0.18.0-rc.5
0.18.0-rc.4
0.18.0-rc.3
0.18.0-rc.2
0.18.0-rc.1
0.17.0
0.16.0
0.15.0
0.15.0-rc.1
0.14.0
0.13.1
0.13.0
0.12.0
0.11.0
0.10.1
0.10.0
0.9.2
0.9.1
0.9.0
0.8.0
0.7.2
0.7.1
0.7.0
0.6.1
0.6.0
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.2
0.3.1
0.3.0
0.2.0
0.1.0
Fast, simple, and robust Cassandra driver for Elixir.
Current section
Files
Jump to
Current section
Files
lib/xandra/error.ex
defmodule Xandra.Error do
@moduledoc """
An exception struct that represents an error returned by Cassandra.
For more information on when this error is returned or raised, see the
documentation for the `Xandra` module.
The `:reason` field represents the reason (as an atom) of the error. For
example, if the query you're trying to execute contains a syntax error,
`:reason` will be `:invalid_syntax`. The `:message` field is a string that
contains the exact error message that Cassandra returned.
Since this struct is an exception, it is possible to raise it with
`Kernel.raise/1`. If the intent is to format errors as strings (for
example, for logging purposes), it is possible to use `Exception.message/1` to
get a formatted version of the error.
"""
@doc """
The exception struct for a Cassandra error.
"""
defexception [:reason, :message, warnings: []]
@typedoc """
The type for a Cassandra error exception.
"""
@type t :: %__MODULE__{
reason: atom,
message: String.t(),
warnings: [String.t()]
}
@doc false
@spec new(atom, String.t(), [String.t()]) :: t
def new(reason, message, warnings)
when is_atom(reason) and is_binary(message) and is_list(warnings) do
%__MODULE__{reason: reason, message: message, warnings: warnings}
end
end