Module: Grape::ErrorFormatter::Xml

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

Class Method Summary collapse

Class Method Details

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


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

def call(message, backtrace, options = {}, env = nil)
  message = Grape::ErrorFormatter::Base.present(message, env)

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