Description
I added a basic error handler using rescue_from :all
that logs exceptions, notifies Airbrake and returns a basic 500 response. Unfortunately this doesn't work as described in the documentation, and this isn't called for all exceptions.
We had an issue with a decorator not being found, and so the formatter (we are using Rabl) was throwing an exception. This was caught here, and thrown again:
lib/grape/middleware/formatter.rb
This was caught in the error middleware and passed directly to error_response
with no options for logging or changing it (other than by hacking around with error_formatter
):
In the end I changed the error middleware to raise an exception for this exception (...) which isn't great, but it allows me to return consistent errors when something goes wrong. It would be great if rescue_from :all
worked as described, and allowed you to rescue from all exceptions 😄