Nebulex.Error exception (Nebulex v3.0.0-rc.1)
View SourceThis exception represents command execution errors. For example, the cache cannot perform a command because it has not started, it does not exist, or the adapter failed to perform it for any reason.
Exception fields
See t/0.
Error reasons
The :reason field can assume the following values:
:timeout- if there is a timeout when executing the cache command.:transaction_aborted- if a transaction execution fails and aborts.:event_listener_already_exists- if another cache entry listener with the same ID already exists.:event_listener_error- if a cache entry event listener fails when processing an event.Exception.t/0- if the underlying adapter fails due to an exception.any/0- the command fails with an adapter-specific error.
Summary
Functions
A callback invoked when a custom formatter module is provided.
Formats the error metadata when not empty.
Types
@type reason() :: atom() | {atom(), any()} | Exception.t()
Error reason type
@type t() :: %Nebulex.Error{ __exception__: true, 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 it is present, it invokesmodule.format_error(reason, metadata)to format the error reason. The argumentmetadatais a keyword with the metadata given to the exception. Seeformat_error/2for more information.:metadata- the metadata contains the options given to the exception excluding the:reasonand:modulethat are part of the exception fields. For example, when raising an exceptionraise Nebulex.Error, reason: :test, foo: :bar, the metadata will be[foo: :bar].
Functions
A callback invoked when a custom formatter module is provided.
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.