Gcode.Result (gcode v1.0.0)

A helper which represents a result type.

This is really just a wrapper around Erlang's ok/error tuples.

Link to this section Summary

Functions

Initialise or match an error value

Is the result an error?

Convert a successful result another result.

Initialise or match an ok value

Is the result ok?

Attempt to unwrap a result and return the inner value. Raises an exception if the result contains an error.

Link to this section Types

Link to this type

error(error)

@type error(error) :: {:error, error}
@type ok(result) :: {:ok, result}
@type t() :: t(any(), any())
@type t(result) :: t(result, any())
Link to this type

t(result, error)

@type t(result, error) :: ok(result) | error(error)

Link to this section Functions

Link to this macro

error(error)

(macro)
@spec error(any()) :: Macro.t()

Initialise or match an error value

@spec error?(t()) :: boolean()

Is the result an error?

Link to this function

map(arg, mapper)

@spec map(t(), (any() -> t())) :: t()

Convert a successful result another result.

Link to this macro

ok(result)

(macro)
@spec ok(any()) :: Macro.t()

Initialise or match an ok value

@spec ok?(t()) :: boolean()

Is the result ok?

@spec unwrap!(t()) :: any() | no_return()

Attempt to unwrap a result and return the inner value. Raises an exception if the result contains an error.