grape
grape copied to clipboard
InvalidMessageBody is no longer rescuable
I'm in the process of upgrading to the current version from an ancient one.
We previously used rescue_from Grape::Exceptions::InvalidMessageBody to catch unknown upload formats and document what the valid upload types are.
However, in https://github.com/ruby-grape/grape/blob/master/lib/grape/exceptions/invalid_message_body.rb a generic error is being raised instead of an InvalidMessageBody.
I don't see a straightforward hook for this; would it make sense to use InvalidMessageBody there?
How so? This is the constructor for InvalidMessageBody.
Sorry, I've clearly pasted the wrong link. It's in https://github.com/ruby-grape/grape/blob/master/lib/grape/middleware/formatter.rb#L100
I would write a spec for your scenario, then try to specialize this error (and anywhere we throw :error) and see what breaks?