29 May
Submitting a Rails documentation patch for rescue_from
The existing documentation for Rails’ rescue_from is lacking in my opinion.
Intuitively, I thought that the following was a simple enough setup:
I was wrong. My thought was that just like rescue blocks, the more specific instances of the Exception should be listed first, followed by more generic Exception classes (perhaps finishing with StandardError should you want a catch-all handler). In fact, the exact opposite ordering is used: The more generic Exception classes should be listed first, followed by more specific classes. Listing a superclass such as StandardError first actually precludes other handlers from running.
Thanks to this comment on ApiDock for the guidance. I have requested access to lifo’s Rails documentation repo on github so that I can commit a docpatch. I also plan to include in the docpatch a better usage example that shows off the rescuing of multiple exception types in one declaration, like so:
Stay tuned…

Respond to this post