Sha256: 9d692c1044f2172262ed0ac080559c68020f1295ef1f8bae4e5ec94e4369b8f1
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
module Vx ; module Lib ; module Instrumentation module Rack HandleExceptionsMiddleware = Struct.new(:app) do IGNORED_EXCEPTIONS = %w{ ActionController::RoutingError } def clean_env(env) env = env.select{|k,v| k !~ /^(action_dispatch|puma|session|rack\.session|action_controller)/ } env['HTTP_COOKIE'] &&= env['HTTP_COOKIE'].scan(/.{80}/).join("\n") env end def notify(exception, env) unless ignore?(exception) Lib::Instrumentation.handle_exception( 'handle_exception.rack', exception, clean_env(env) ) end end def call(env) begin response = app.call(env) rescue Exception => ex notify ex, env raise ex end if ex = framework_exception(env) notify ex, env end response end def framework_exception(env) env['rack.exception'] || env['action_dispatch.exception'] end def ignore?(ex) IGNORED_EXCEPTIONS.include? ex.class.name end end end end ; end ; end
Version data entries
4 entries across 4 versions & 1 rubygems