Cachex v3.2.0 Cachex.Errors View Source

Module containing all error definitions used in the codebase.

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.

This module is provided to allow functions to return short errors, using the easy syntax of error(:short_name) to generate a tuple of { :error, :short_name } but also to allow them to be converted to a readable form as needed, rather than bloating blocks with potentially large error messages.

Link to this section 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.

Link to this section Functions

Link to this macro

error(key)

View Source (macro)
error(atom()) :: {:error, 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.

Returns the list of known error keys.

Link to this function

long_form(error)

View Source
long_form(atom()) :: 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.