An Elixir library providing helpers for working with exceptions, offering a hybrid approach between tagged status and optimistic flow.
Exceptional is an Elixir library that simplifies exception handling by providing convenient helpers for working with plain Elixir values. It aims to give full control back to calling functions, making error handling more flexible and Elixir-native through features like converting raising functions to return exceptions, propagating exceptions in pipelines, and normalizing error representations.
Elixir developers who need more control over exception handling in their code, particularly those working with mixed error patterns (tagged tuples, exceptions, Erlang errors) and seeking a simpler alternative to error monads.
Developers choose Exceptional because it offers a hybrid approach that behaves similarly to an error monad but in a more Elixir-y way, prioritizing simplicity and convenience while maintaining caller control, eliminating the need for separate bang functions through operators like `>>>`.
Helpers for Elixir exceptions
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The `safe/1` function declaws raising functions to return exceptions instead, eliminating the need for try/catch blocks and making error handling safer, as shown in the Make Safe examples with `Enum.fetch!`.
The `~>` operator allows exceptions to propagate through pipelines, escaping on error without raising, simplifying control flow in sequential operations like mapping and summing.
`normalize/1` converts Erlang-style error tuples into Elixir exceptions, ensuring consistent error representation across mixed Elixir and Erlang codebases, though it may require custom converters for edge cases.
The `>>>` operator raises exceptions if present, removing the need for separate bang functions (e.g., `foo!`), as demonstrated in the Finally Raise section with examples like `Foo.foo!`.
Introducing non-standard operators like `~>` and `>>>` increases the learning curve and can reduce code readability for teams not familiar with Exceptional, potentially leading to maintenance challenges.
Compared to error monads, Exceptional is less powerful and doesn't provide the same level of composability, as admitted in the philosophy section, making it unsuitable for theoretically rigorous error handling.
Error normalization might not detect all error types, requiring custom converters that add boilerplate and complexity, as shown in the Normalize Errors examples with custom function handling.