Skip to content
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

Merged
merged 1 commit into from
Apr 1, 2015
Merged

Conversation

sunnyrjuneja
Copy link
Contributor

I was having a similar problem with ValidationErrors#to_json as I was with ValidationErrors#as_json (see: #889). If there's preferred fix, please let me know.

@sunnyrjuneja
Copy link
Contributor Author

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)
Copy link
Member

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.

@dblock
Copy link
Member

dblock commented Apr 1, 2015

This needs a CHANGELOG entry and please squash your commits.

@sunnyrjuneja
Copy link
Contributor Author

@dblock Thanks for your fast response. I've applied your recommendations. Let me know if you have anymore feedback.

@dblock
Copy link
Member

dblock commented Apr 1, 2015

I like this, merging.

dblock added a commit that referenced this pull request Apr 1, 2015
@dblock dblock merged commit 60ecad4 into ruby-grape:master Apr 1, 2015
@u2
Copy link
Contributor

u2 commented Apr 2, 2015

0.28.0 (10/12/2014)

New features

New cop ExtraSpacing points out unnecessary spacing in files.

This feature has been released in 0.28.0, I think it's a bug of rubocop, anyway I create a commit for updating robocop version.

@binary1101
Copy link

still doesn't work in 0.14.0

class Twitter::API < Grape::API
  format :json
  helpers do
    def server_error!
      error!({ error: 'Server error.' }, 500, { 'Content-Type' => 'text/error' })
    end
  end

  rescue_from :all do |e|
    server_error!
  end
end

@dblock
Copy link
Member

dblock commented Feb 22, 2016

@binary1101 how does it not work exactly? Open a new issue please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants