# Error handling in Elixir

DevFeed: [Error handling in Elixir](<https://devfeed.tech/articles/error-handling-in-elixir-96525.md>)

Original publisher: [Read original article](<https://www.honeybadger.io/blog/elixir-error-handling/>)

Author: Paweł Świątkowski

Published: 2026-10-22T07:00:00Z

Content type: article

Language: en

Sources: [Honeybadger](<https://devfeed.tech/sources/honeybadger.md>)

Topics: [Elixir](<https://devfeed.tech/topics/elixir.md>), [Error Handling](<https://devfeed.tech/topics/error-handling.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [bestpractice](<https://devfeed.tech/topics/bestpractice.md>)

Tags: [2](<https://devfeed.tech/tags/2.md>), [3](<https://devfeed.tech/tags/3.md>), [about](<https://devfeed.tech/tags/about.md>), [alerts](<https://devfeed.tech/tags/alerts.md>), [all](<https://devfeed.tech/tags/all.md>), [also](<https://devfeed.tech/tags/also.md>), [api](<https://devfeed.tech/tags/api.md>), [app](<https://devfeed.tech/tags/app.md>), [article](<https://devfeed.tech/tags/article.md>), [best](<https://devfeed.tech/tags/best.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [developer](<https://devfeed.tech/tags/developer.md>), [elixir](<https://devfeed.tech/tags/elixir.md>), [elixir-articles](<https://devfeed.tech/tags/elixir-articles.md>), [error](<https://devfeed.tech/tags/error.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [handling](<https://devfeed.tech/tags/handling.md>), [practices](<https://devfeed.tech/tags/practices.md>), [signal](<https://devfeed.tech/tags/signal.md>), [this](<https://devfeed.tech/tags/this.md>), [with](<https://devfeed.tech/tags/with.md>)

## AI overview

Elixir offers several ways to signal failure, and the article recommends choosing based on whether it is expected and who can act on it. Use tagged tuples such as `{:error, :not_found}` for anticipated failures; keep reasons as atoms so callers can translate them into context appropriate messages, and use structs when they provide useful detail. Exceptions generally mark programmer misuse or unexpected infrastructure failures; rescue specific exceptions when recovery or reporting is appropriate, and use `reraise` to preserve the stacktrace. Division by zero is given as a conventional exception. Exits signal process termination and are handled with `catch` or usually by supervisors; throws pass values up the stack and are discouraged unless needed. The article suggests reporting errors with Honeybadger, then re-raising or re-emitting signals when appropriate. Its closing guidance favors tuples for expected failures, built-in exceptions for misuse, custom exceptions for failures without a suitable built-in type, and catching exits or throws from Erlang libraries.

## Source excerpt

With so many ways to signal about something going wrong, an Elixir developer might sometimes feel lost. Read this article to learn when to use which signal and what are the best practices for the different kinds.