Method: Grape::Middleware::Error#format_message

Defined in:
lib/grape/middleware/error.rb

#format_message(message, backtrace, original_exception = nil) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/grape/middleware/error.rb', line 79

def format_message(message, backtrace, original_exception = nil)
  format = env[Grape::Env::API_FORMAT] || options[:format]
  formatter = Grape::ErrorFormatter.formatter_for(format, options)
  throw :error,
        status: 406,
        message: "The requested format '#{format}' is not supported.",
        backtrace: backtrace,
        original_exception: original_exception unless formatter
  formatter.call(message, backtrace, options, env, original_exception)
end