-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error! in rescue from blocks #974
Conversation
Also, it's possible to remove error_response and sub in error! but it was getting pretty confusing. There seems to be a bit of coupling with the method signature of error_response and the rest of the code. I can send another PR for that or append it here. |
@@ -1031,7 +1031,7 @@ You can rescue a `Grape::Exceptions::ValidationErrors` and respond with a custom | |||
```ruby | |||
format :json | |||
subject.rescue_from Grape::Exceptions::ValidationErrors do |e| | |||
rack_response e.to_json, 400 | |||
error!(e, 400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I would omit the parenthesis here.
This needs a CHANGELOG entry and please squash your commits. |
@dblock Thanks for your fast response. I've applied your recommendations. Let me know if you have anymore feedback. |
I like this, merging. |
This feature has been released in |
still doesn't work in 0.14.0
|
@binary1101 how does it not work exactly? Open a new issue please |
I was having a similar problem with
ValidationErrors#to_json
as I was withValidationErrors#as_json
(see: #889). If there's preferred fix, please let me know.