A Ruby gem for nesting exceptions to preserve error context when re-raising custom errors.
Nesty is a Ruby gem that provides nested exception support, allowing developers to rescue errors from external libraries and re-raise their own custom errors while preserving the original error context. It solves the problem of losing debugging information when abstracting away library-specific errors in applications or libraries.
Ruby developers building libraries or applications that need to abstract external library errors and expose custom error types to clients.
Developers choose Nesty because it offers a simple, lightweight way to maintain error context across re-raised exceptions, improving debuggability without complicating error handling logic.
Nested exceptions for Ruby
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables error classes to nest other exceptions, preserving the original error chain for debugging, as demonstrated with explicit nesting in the HappyError example.
Automatically nests rescued errors when raising new errors without explicit passing, simplifying code by reducing boilerplate in rescue blocks.
Formats stacktraces to include messages from all nested errors at appropriate lines, maintaining readability, illustrated with the A, B, C example in the README.
Adds nesting capability by including a module or inheriting from a base class, making it easy to integrate into existing error classes with minimal changes.
Follows a minimalist philosophy, so it lacks advanced features like error serialization, logging integration, or automatic handling for non-standard exceptions.
Ruby 2.1+ has native exception chaining via the 'cause' attribute, which may make Nesty unnecessary for modern projects unless specific formatting or implicit nesting is needed.
Requires explicitly including the Nesty module in each custom error class, which can be cumbersome in large codebases with many error types.