module TraceView::Grape::Middleware::Error
Public Class Methods
included(klass)
click to toggle source
# File lib/traceview/frameworks/grape.rb, line 54 def self.included(klass) ::TraceView::Util.method_alias(klass, :error_response, ::Grape::Middleware::Error) end
Public Instance Methods
error_response_with_traceview(error = {})
click to toggle source
# File lib/traceview/frameworks/grape.rb, line 58 def error_response_with_traceview(error = {}) status, headers, body = error_response_without_traceview(error) if TraceView.tracing? # Since Grape uses throw/catch and not Exceptions, we manually log # the error here. kvs = {} kvs[:ErrorClass] = 'GrapeError' kvs[:ErrorMsg] = error[:message] ? error[:message] : "No message given." kvs[:Backtrace] = ::TraceView::API.backtrace if TraceView::Config[:grape][:collect_backtraces] ::TraceView::API.log(nil, 'error', kvs) # Since calls to error() are handled similar to abort in Grape. We # manually log the rack exit here since the original code won't # be returned to xtrace = TraceView::API.log_end('rack', :Status => status) if headers && TraceView::XTrace.valid?(xtrace) unless defined?(JRUBY_VERSION) && TraceView.is_continued_trace? headers['X-Trace'] = xtrace if headers.is_a?(Hash) end end end [status, headers, body] end