serum v1.2.0 Serum.Result View Source

This module defines types for positive results or errors returned by functions in this project.

Link to this section Summary

Functions

Takes a list of results without value and checks if there is no error.

Takes a list of results with values and checks if there is no error.

Gets a human friendly message from the given result.

Prints an error object in a beautiful format.

Link to this section Types

Link to this type

err_details()

View Source
err_details() :: msg_detail() | full_detail() | nest_detail()
Link to this type

error()

View Source
error() :: {:error, err_details()}
Link to this type

full_detail()

View Source
full_detail() :: {binary(), binary(), non_neg_integer()}
Link to this type

msg_detail()

View Source
msg_detail() :: binary()
Link to this type

nest_detail()

View Source
nest_detail() :: {term(), [error()]}
Link to this type

t(type)

View Source
t(type) :: {:ok, type} | error()

Link to this section Functions

Link to this function

aggregate(results, msg)

View Source
aggregate([t()], term()) :: t()

Takes a list of results without value and checks if there is no error.

Returns :ok if there is no error.

Returns an aggregated error object if there is one or more errors.

Link to this function

aggregate_values(results, msg)

View Source
aggregate_values([t(term())], term()) :: t([term()])

Takes a list of results with values and checks if there is no error.

If there is no error, it returns {:ok, list} where list is a list of returned values.

Returns an aggregated error object if there is one or more errors.

Link to this function

get_message(result, depth)

View Source
get_message(t() | t(term()), non_neg_integer()) :: binary()

Gets a human friendly message from the given result.

You can control the indentation level by passing a non-negative integer to the depth parameter.

Link to this function

show(result, indent \\ 0)

View Source
show(t() | t(term()), non_neg_integer()) :: :ok

Prints an error object in a beautiful format.