Errata - Structured error handling for Elixir

Announcing Errata, an Elixir library for consistent and structured error handling.

Errata is an Elixir library that promotes a consistent and structured approach to error handling.

Errata provides support for defining custom structured error types, which can either be returned as error values or raised as exceptions.

Errata errors are named, structured types that represent error conditions in an application or library. Being named types means that errors have a unique and meaningful name within a particular context. Being structured types means that errors have a well-defined, consistent structure identifying the nature of the error, and can also have arbitrary contextual information attached to them for logging or debugging purposes.

https://hexdocs.pm/errata/

7 Likes

This looks interesting! Question: the docs say

Using the create/1 macro, on the other hand, fills in the :env field of the error struct with information from the current __ENV__ struct and the current stacktrace.

I thought that was only available in rescue blocks since System.stacktrace/0 was deprecated years ago - for performance reasons IIRC. Are there any performance implications of using the create/1 macro?

Hi @nathanl,

The create/1 macro uses Process.info(self(), :current_stacktrace) to fill in the stacktrace. I’m not sure about the efficiency of this function, but I would venture to say that if you are using create/1 for creating Errata errors in your codebase then it would probably not be on the critical path and would not affect overall system performance to any appreciable degree.

1 Like

Yeah, hopefully you’re not creating errors in a tight loop. :sweat_smile: