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