8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/nadir/middleware/rack.rb', line 8
def call(env)
begin
response = @app.call(env)
rescue Exception => exception
begin
request = ActionDispatch::Request.new env
= request..env.select{|k, _| k.in?(ActionDispatch::Http::::CGI_VARIABLES) || k =~ /^HTTP_/}
location = request.parameters.values_at('controller', 'action').compact.join('#')
location = location.presence || "#{headers['REQUEST_METHOD']} #{headers['PATH_INFO']}"
request_params = {
headers: ,
params: request.parameters,
remote_ip: request.remote_ip,
user: {}
}
if request.env['warden'] && request.env['warden'].respond_to?(:user)
request_params[:user][:id] = request.env['warden'].user&.id
end
Nadir.notify exception, location: location, request: request_params
rescue => e
Nadir.logger.error "[Nadir] Internal error: #{e.inspect}"
end
raise
end
response
ensure
end
|