Module: Grape::ErrorFormatter::Json

Defined in:
lib/grape/error_formatter/json.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) call(message, backtrace, options = {}, env = nil)



5
6
7
8
9
10
11
# File 'lib/grape/error_formatter/json.rb', line 5

def call(message, backtrace, options = {}, env = nil)
  result = message.is_a?(Hash) ? message : { error: message }
  if (options[:rescue_options] || {})[:backtrace] && backtrace && !backtrace.empty?
    result = result.merge(backtrace: backtrace)
  end
  MultiJson.dump(result)
end