View Source Cachex.Error exception (Cachex v4.0.2)

Module containing all error definitions used in the codebase.

This module allows users to catch Cachex errors in a separate block to other errors/exceptions rather than using stdlib errors:

iex> try do
...>   Cachex.put!(:cache, "key", "value")
...> rescue
...>   e in Cachex.Error -> e
...> end

All error messages (both shorthand and long form) can be found in this module, including the ability to convert from the short form to the long form using the long_form/1 function.

Summary

Functions

Generates a tagged :error Tuple at compile time.

Returns the list of known error keys.

Converts an error identifier to it's longer form.

Functions

@spec error(shortname :: atom()) :: {:error, shortname :: atom()}

Generates a tagged :error Tuple at compile time.

The provided error key must be contained in the list of known identifiers returned be known/0, otherwise this call will fail.

@spec known() :: [shortname :: atom()]

Returns the list of known error keys.

@spec long_form(shortname :: atom()) :: description :: binary()

Converts an error identifier to it's longer form.

Error identifiers should be atoms and should be contained in the list of errors returned by known/0. The return type from this function will always be a binary.