def render_error(e)
logger.error e.inspect
- if !e.is_a? RequestError and (e.respond_to? :backtrace and e.backtrace)
- logger.error e.backtrace.collect { |x| x + "\n" }.join('')
+ if e.respond_to? :backtrace and e.backtrace
+ # This will be cleared by lograge after adding it to the log.
+ # Usually lograge would get the exceptions, but in our case we're catching
+ # all of them with exception handlers that cannot re-raise them because they
+ # don't get propagated.
+ Thread.current[:exception] = e.inspect
+ Thread.current[:backtrace] = e.backtrace.collect { |x| x + "\n" }.join('')
end
if (@object.respond_to? :errors and
@object.errors.andand.full_messages.andand.any?)
client_ipaddr: event.payload[:client_ipaddr],
client_auth: event.payload[:client_auth],
}
+
+ # Lograge adds exceptions not being rescued to event.payload, but we're
+ # catching all errors on ApplicationController so we look for backtraces
+ # elsewhere.
+ if !Thread.current[:backtrace].nil?
+ payload.merge!(
+ {
+ exception: Thread.current[:exception],
+ exception_backtrace: Thread.current[:backtrace],
+ }
+ )
+ Thread.current[:exception] = nil
+ Thread.current[:backtrace] = nil
+ end
+
exceptions = %w(controller action format id)
params = event.payload[:params].except(*exceptions)