Flux Redis v0.0.2 FluxRedis.Error exception View Source

FluxRedis error module/struct.

Link to this section Summary

Functions

Generate message String.t/0 based on :reason and :metadata.

Generate raw message String.t/0 based on :reason to be used by external modules or services, such as Gettext.

Link to this section Types

Link to this type

opts()

View Source
opts() :: [{:format, :elixir | :python}]

FluxRedis.Error.t/0 message options.

Link to this type

t()

View Source (since 0.0.1)
t() :: %FluxRedis.Error{__exception__: term(), metadata: map(), reason: atom()}

FluxRedis error struct/0.

Every FluxRedis error is a FluxRedis.Error.t/0.

Redix errors are merged with FluxRedis.Error.t/0 and can be accessed with :detail key inside :metadatamap/0.

Link to this section Functions

Link to this function

message(error)

View Source (since 0.0.1)
message(FluxRedis.Error.t()) :: String.t()

Generate message String.t/0 based on :reason and :metadata.

Parameters

Examples

iex> error = %FluxRedis.Error{reason: :key_not_found, metadata: %{key: :id}}
...> FluxRedis.Error.message(error)
"data does not have key 'id'"
Link to this function

message_raw(error, opts \\ [])

View Source (since 0.0.1)
message_raw(FluxRedis.Error.t(), opts()) :: String.t()

Generate raw message String.t/0 based on :reason to be used by external modules or services, such as Gettext.

Parameters

  • error - The FluxRedis.Error.t/0.

  • opts - The opts/0keyword/0. Defaults to []. Options are:

    • :format - Format message keys to a language standard. Options are:

      • :elixir - Message keys are defined as "%{key}", satisfying the Gettext pattern.

      • :python - Message keys are defined as "%(key)s", satisfying the python gettext pattern.

Examples

iex> error = %FluxRedis.Error{reason: :key_not_found, metadata: %{key: :id}}
...> FluxRedis.Error.message_raw(error, format: :python)
"data does not have key '%(key)s'"