Erlang-style supervisor error handling for Clojure with pre/post conditions and hooks.
Dire is a Clojure library that provides sophisticated error handling mechanisms inspired by Erlang's supervisor model. It helps developers separate error logic from business logic by offering comprehensive hooks, preconditions, and postconditions for functions.
Clojure developers building robust, fault-tolerant applications who need declarative error handling and supervision patterns.
Developers choose Dire for its clean separation of error and business logic, Erlang-style supervision for managing failures, and composable constructs like pre/post conditions and hooks that go beyond basic try/catch.
Erlang-style supervisor error handling for Clojure
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Implements supervisor patterns for fault tolerance, enabling self-correcting handlers that can retry or fix issues, as demonstrated in the self-correcting error handling example with file reading.
Uses with-handler! and supervise to cleanly separate error logic from business logic, promoting maintainability and reducing coupling, as shown in the simple divider function examples.
Offers pre-hooks, post-hooks, eager pre-hooks, and wrap-hooks for injecting behavior at various execution stages, detailed in the hooks sections with examples like logging and result checking.
Seamlessly integrates with Slingshot for map-based or predicate-based exception dispatch, enhancing error handling precision, as illustrated in the map and predicate dispatch examples.
Multiple pre-hooks evaluate in arbitrary order, as noted in the README, which can lead to unpredictable behavior if hook sequence is critical for application logic.
Declarative setup requires managing handlers and hooks separately for each function, potentially complicating codebases as they scale, evident from the verbose examples for each feature.
The layered evaluation model (e.g., eager pre-hooks, preconditions, post-hooks) adds latency to function calls, which might impact performance-sensitive applications.