Sha256: 6c01e7243419bd8cb1014cafcc0e101f5bc7f25a0727762484707a8af64f1148

Contents?: true

Size: 877 Bytes

Versions: 5

Compression:

Stored size: 877 Bytes

Contents

# frozen_string_literal: true

module Grape
  module ErrorFormatter
    module Txt
      extend Base

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

          result = message.is_a?(Hash) ? ::Grape::Json.dump(message) : message
          Array.wrap(result).tap do |final_result|
            rescue_options = options[:rescue_options] || {}
            if rescue_options[:backtrace] && backtrace.present?
              final_result << 'backtrace:'
              final_result.concat(backtrace)
            end
            if rescue_options[:original_exception] && original_exception
              final_result << 'original exception:'
              final_result << original_exception.inspect
            end
          end.join("\r\n ")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-2.2.0 lib/grape/error_formatter/txt.rb
grape-2.1.3 lib/grape/error_formatter/txt.rb
grape-2.1.2 lib/grape/error_formatter/txt.rb
grape-2.1.1 lib/grape/error_formatter/txt.rb
grape-2.1.0 lib/grape/error_formatter/txt.rb