Skip to content

There's no clean way to override the default error formatter #297

Closed
@dblock

Description

@dblock

If you request a format that the API didn't know about, and call error!, you get the default error formatter, which is .txt. Without monkey patching you cannot override it.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions