Posted over 6 years ago. Visible to the public. Repeats. Linked content.

skorks/nesty

Nested exceptions for Ruby:

When you rescue an error and then re-raise your own, you don't have to lose track of what actually occured, you can keep/nest the old error in your own and the stacktrace will reflect the cause of the original error.

This is awesome when you classes convert exception classes. I now always subclass Nesty::NestedStandardError instead of StandardError for my own error classes.

About Exception#cause

Ruby 2.1 has a built-in mechanism with Exception#cause, which serves a similiar purpose as Nesty. However, any code printing your stack trace (Exception Notifier, Airbrake, Sentry, your IRB shell, etc.) needs to be aware of Exception#cause. Nesty on the other hand-merges the stack trace array of the current and previous exception.

This way Nesty does not need to rely on other tools to display Exception#cause.

There is also a backport of Exception#cause for older Rubies Archive .

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Avatar
Henning Koch
Last edit:
over 5 years ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more