Module: TraceView::Grape::Middleware::Error
- Defined in:
- lib/traceview/frameworks/grape.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
49 50 51 |
# File 'lib/traceview/frameworks/grape.rb', line 49 def self.included(klass) ::TraceView::Util.method_alias(klass, :error_response, ::Grape::Middleware::Error) end |
Instance Method Details
#error_response_with_traceview(error = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/traceview/frameworks/grape.rb', line 53 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 |