Sha256: bec562e3c526d0a06381c885e78236fdc99f015829bb50e72e7e73c9fb0fa5e3

Contents?: true

Size: 532 Bytes

Versions: 5

Compression:

Stored size: 532 Bytes

Contents

if defined?(Grape)
  module Grape
    module ErrorFormatter
      module Json
        class << self
          def call(message, backtrace, options = {}, env = nil)
            result = message.is_a?(Napa::JsonError) ? message : Napa::JsonError.new(:api_error, message)

            if (options[:rescue_options] || {})[:backtrace] && backtrace && !backtrace.empty?
              result = result.to_h.merge(backtrace: backtrace)
            end
            MultiJson.dump(result)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
napa-0.5.0 lib/napa/grape_extensions/error_formatter.rb
napa-0.4.3 lib/napa/grape_extensions/error_formatter.rb
napa-0.4.1 lib/napa/grape_extensions/error_formatter.rb
napa-0.4.0 lib/napa/grape_extensions/error_formatter.rb
napa-0.3.0 lib/napa/grape_extensions/error_formatter.rb