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

Wrong number of parameters for an error formatter for an undefined formatter #296

Closed
dblock opened this issue Dec 25, 2012 · 1 comment
Closed

Comments

@dblock
Copy link
Member

dblock commented Dec 25, 2012

error_formatter/base yields a broken block (missing env parameter) as a formatter for an unknown format

"wrong number of arguments (4 for 3)"                                                                                           | ETA:  --:--:--
/home/dblock/.rvm/gems/ruby-1.9.3-p194-perf/gems/grape-.2.3/lib/grape/error_formatter/base.rb:21:in `block in formatter_for'
/home/dblock/.rvm/gems/ruby-1.9.3-p194-perf/gems/grape-0.2.3/lib/grape/middleware/error.rb:66:in `call'"
@dblock
Copy link
Member Author

dblock commented Dec 25, 2012

Monkey patch to fix:

module Grape
  module ErrorFormatter
    module Base
      class << self
        def formatter_for(api_format, options = {})
          spec = formatters(options)[api_format]
          case spec
          when nil
            Grape::ErrorFormatter::Txt
          when Symbol
            method(spec)
          else
            spec
          end
        end
      end
    end
  end
end

@dblock dblock closed this as completed in 8adf0f9 Dec 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant