Sha256: 840beede2c0c8be6a4099c9787be429eaf23832dc3073d84b72e8029d668af2a
Contents?: true
Size: 937 Bytes
Versions: 10
Compression:
Stored size: 937 Bytes
Contents
# frozen_string_literal: true module Grape module ErrorFormatter module Json extend Base class << self def call(message, backtrace, options = {}, env = nil, original_exception = nil) result = wrap_message(present(message, env)) rescue_options = options[:rescue_options] || {} if rescue_options[:backtrace] && backtrace && !backtrace.empty? result = result.merge(backtrace: backtrace) end if rescue_options[:original_exception] && original_exception result = result.merge(original_exception: original_exception.inspect) end ::Grape::Json.dump(result) end private def wrap_message(message) if message.is_a?(Exceptions::ValidationErrors) || message.is_a?(Hash) message else { error: message } end end end end end end
Version data entries
10 entries across 10 versions & 2 rubygems