# How to format return values

**URL:** <https://forum.elixirforum.com/t/how-to-format-return-values/27449>\
**Category:** Questions\
**Tags:** best-practice\
**Created:** [December 9, 2019, 9:41am UTC](https://forum.elixirforum.com/t/how-to-format-return-values/27449 "2019-12-09T09:41:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tty](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/t/0ea827/32.png) [@tty](https://forum.elixirforum.com/u/tty)\
**Post date:** [December 9, 2019, 10:15am UTC](https://forum.elixirforum.com/t/how-to-format-return-values/27449/2 "2019-12-09T10:15:10Z")

</div>

From laziness we treat `value` as `{:ok, value}` but if `value` is an error code then it should be `{:error, value}`.

A status should be descriptive and makes sense for the callee when pattern matching.

E.g. if a function spec is  
`{:ok, :connected} | {:ok, :received} | {:error, error_code}` it can easily be changed to `:connected | :received | {:error, error_code}` without losing information.

---

_[View the full topic](https://forum.elixirforum.com/t/how-to-format-return-values/27449)._
