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

Returns a new instance of 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
# File 'lib/sentry/user_informer.rb', line 20

def call(env)
  status, headers, body = @app.call(env)
  if (event_id = env["sentry.error_event_id"]) # see https://github.com/getsentry/sentry-ruby/pull/1849
    replacement = format(Sentry::UserInformer.template, event_id:)
    body = body.map { |chunk| chunk.gsub(Sentry::UserInformer.placeholder, replacement) }
    headers[::Rack::CONTENT_LENGTH] = body.sum(&:bytesize).to_s # body grew, so the previous value is stale
  end
  [status, headers, body]
end