Raised, or returned in an {:error, _} tuple, when a command fails. For
example, the adapter could not run it, it timed out, or a transaction was
aborted.
Exception fields
See t/0.
Error reasons
The :reason field can be one of:
:timeout- the command timed out.:transaction_aborted- a transaction failed and was aborted.:event_listener_already_exists- another cache entry listener with the same ID is already registered.:event_listener_error- a cache entry event listener failed while processing an event.Exception.t/0- the adapter raised an exception.any/0- the command failed with an adapter-specific error.
Summary
Functions
Formats the error message. A custom formatter module (see the :module
field) must define a function with the same name and arguments.
Formats the error metadata when not empty.
Types
@type reason() :: any()
Error reason type.
Usually an atom, a {atom, term} tuple, or an exception, but adapters may
use any term.
@type t() :: %Nebulex.Error{ __exception__: term(), metadata: keyword(), module: module(), reason: reason() }
The type for this exception struct.
This exception has the following public fields:
:reason- the error reason. It can be one of the Nebulex-specific reasons described in the "Error reasons" section in the module documentation.:module- a custom error formatter module. When present, the message is built withmodule.format_error(reason, metadata), wheremetadatais the keyword list given to the exception. Seeformat_error/2.:metadata- the options given to the exception, minus:reasonand:module. For example,raise Nebulex.Error, reason: :test, foo: :bargives the metadata[foo: :bar].
Functions
Formats the error message. A custom formatter module (see the :module
field) must define a function with the same name and arguments.
Arguments
reason- the error reason.metadata- a keyword with the metadata given to the exception.
For example, if an adapter returns:
wrap_error Nebulex.Error,
reason: :my_reason,
module: MyAdapter.Formatter,
foo: :barthe exception invokes:
MyAdapter.Formatter.format_error(:my_reason, foo: :bar)
Formats the error metadata when not empty.