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.



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

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



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

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: 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