Module: Grape::ErrorFormatter::Xml

Extended by:
Base
Defined in:
lib/grape/error_formatter/xml.rb

Class Method Summary collapse

Methods included from Base

present

Class Method Details

.call(message, backtrace, options = {}, env = nil, original_exception = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/grape/error_formatter/xml.rb', line 9

def call(message, backtrace, options = {}, env = nil, original_exception = nil)
  message = present(message, env)

  result = message.is_a?(Hash) ? message : { message: message }
  rescue_options = options[:rescue_options] || {}
  result = result.merge(backtrace: backtrace) if rescue_options[:backtrace] && backtrace && !backtrace.empty?
  result = result.merge(original_exception: original_exception.inspect) if rescue_options[:original_exception] && original_exception
  result.respond_to?(:to_xml) ? result.to_xml(root: :error) : result.to_s
end