Class: Sentry::UserInformer::ExceptionRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry/user_informer.rb

Overview

render captured exception so users can click it testing: set ‘config.consider_all_requests_local = false` and add `raise ’testing’‘ to an action

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ExceptionRenderer



16
17
18
# File 'lib/sentry/user_informer.rb', line 16

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/sentry/user_informer.rb', line 20

def call(env)
  Thread.current[Sentry::UserInformer::SENTRY_EVENT_ID] = nil # reset to not keep old exception around
  status, headers, body = @app.call(env)
  if (event_id = Thread.current[Sentry::UserInformer::SENTRY_EVENT_ID])
    replacement = format(Sentry::UserInformer.template, event_id: event_id)
    body = body.map { |chunk| chunk.gsub(Sentry::UserInformer.placeholder, replacement) }
    headers["Content-Length"] = body.sum(&:bytesize).to_s # not sure if this is needed, but it does not hurt
  end
  [status, headers, body]
end