exceptiontrap 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/generators/exceptiontrap/templates/exceptiontrap.yml +3 -3
- data/lib/exceptiontrap/data.rb +17 -35
- data/lib/exceptiontrap/rack.rb +3 -2
- data/lib/exceptiontrap/railtie.rb +1 -1
- data/lib/exceptiontrap/version.rb +1 -1
- data/lib/exceptiontrap.rb +0 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25618a77b83b7ef0c13663112662880e35f17a0af53f88e3c1421fe621aed816
|
4
|
+
data.tar.gz: a8d8f88e92861949b4ce464f6965287bcce8fc3a022e1a7ec13353202bbf0f9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fac4396f56131cb0cb791bc02eb5cb4f5be99b876965caae23f8d36615f38fa6a12e1ee1a1b1229623ad1266ac6053e4eccabfe148344cec379ee1bd97aee7c0
|
7
|
+
data.tar.gz: 48cb93606af8e72c75b6745592d73015cec4c0e379dbf2dfab00e2889fc27046a79fbb9af1dbf0b224c38cfa7c20aa2bf4df8e035681736620ff941e2646aac5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -52,7 +52,7 @@ end
|
|
52
52
|
|
53
53
|
There is no automatic integration into [Resque](https://github.com/resque/resque) yet. Meanwhile you can let Exceptiontrap notifiy you about errors using its `notify` method inside Resque's `on_failure` hook.
|
54
54
|
|
55
|
-
You can also create a module with Exceptiontrap enabled and integrate
|
55
|
+
You can also create a module with Exceptiontrap enabled and integrate it.
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
module ExceptiontrapJob
|
@@ -71,7 +71,7 @@ end
|
|
71
71
|
|
72
72
|
## Known Issues / Todo
|
73
73
|
|
74
|
-
Optimize and
|
74
|
+
Optimize and add the test suite.
|
75
75
|
|
76
76
|
|
77
|
-
Copyright (c)
|
77
|
+
Copyright (c) 2019 [Torsten Bühl], released under the MIT license
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Exceptiontrap Config File
|
2
2
|
|
3
|
-
# If ENV['
|
4
|
-
# This happens for example
|
3
|
+
# If ENV['EXCEPTIONTRAP_API_KEY'] is set, it will be used instead of the following api-key
|
4
|
+
# This happens for example if you use the Exceptiontrap add-on on Heroku
|
5
5
|
api-key: <%= api_key %>
|
6
6
|
ssl: true
|
7
7
|
timeout: 5000
|
@@ -16,4 +16,4 @@ ignoreExceptions:
|
|
16
16
|
filterParams:
|
17
17
|
- 'password'
|
18
18
|
- 'password_confirmation'
|
19
|
-
- 's3-key'
|
19
|
+
- 's3-key'
|
data/lib/exceptiontrap/data.rb
CHANGED
@@ -1,26 +1,7 @@
|
|
1
1
|
module Exceptiontrap
|
2
|
+
# TODO: Rewrite this class
|
2
3
|
class Data
|
3
4
|
class << self
|
4
|
-
# TODO: Remove the duplication or separate classes
|
5
|
-
# Creates Notification Data for action controller requests (Rails 2)
|
6
|
-
def rails2_data(exception, request, session, response)
|
7
|
-
data = {
|
8
|
-
'notifier' => NOTIFIER_NAME,
|
9
|
-
'name' => exception.class.name,
|
10
|
-
'message' => exception.message,
|
11
|
-
'location' => location(exception),
|
12
|
-
'root' => application_root.to_s,
|
13
|
-
'app_environment' => application_environment,
|
14
|
-
'request_uri' => request.url || REQUEST_URI,
|
15
|
-
'request_params' => clean_params(request.params),
|
16
|
-
'request_session' => clean_params(extrap_session_data(session)),
|
17
|
-
'environment' => clean_params(request.env),
|
18
|
-
'trace' => clean_backtrace(exception.backtrace),
|
19
|
-
'request_components' => { :controller => request.params[:controller], :action => request.params[:action] }
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
# Creates Notification Data for rack requests (Rails 3)
|
24
5
|
def rack_data(exception, env = {})
|
25
6
|
components = {}
|
26
7
|
if env["action_dispatch.request.parameters"] != nil
|
@@ -41,8 +22,8 @@ module Exceptiontrap
|
|
41
22
|
'app_environment' => application_environment,
|
42
23
|
'request_uri' => rack_request_url(env),
|
43
24
|
'request_params' => clean_params(env['action_dispatch.request.parameters']),
|
44
|
-
'request_session' => clean_params(
|
45
|
-
'environment' => clean_params(env),
|
25
|
+
'request_session' => clean_params(session_data(env)),
|
26
|
+
'environment' => clean_params(strip_env(env)),
|
46
27
|
'trace' => clean_backtrace(exception.backtrace),
|
47
28
|
'request_components' => components
|
48
29
|
}
|
@@ -86,8 +67,9 @@ module Exceptiontrap
|
|
86
67
|
end
|
87
68
|
|
88
69
|
# Deletes params from env / set in config file
|
89
|
-
def
|
90
|
-
|
70
|
+
def strip_env(env)
|
71
|
+
keys_to_remove = ['rack.request.form_hash', 'rack.request.form_vars', 'async.callback']
|
72
|
+
env.reject { |k,v| keys_to_remove.include?(k) }
|
91
73
|
end
|
92
74
|
|
93
75
|
# Replaces parameter values with a string / set in config file
|
@@ -112,9 +94,10 @@ module Exceptiontrap
|
|
112
94
|
end
|
113
95
|
end
|
114
96
|
|
115
|
-
|
116
|
-
|
97
|
+
def session_data(env)
|
98
|
+
session = env['action_dispatch.request.session']
|
117
99
|
return if session == nil
|
100
|
+
|
118
101
|
if session.respond_to?(:to_hash)
|
119
102
|
session.to_hash
|
120
103
|
else
|
@@ -134,18 +117,17 @@ module Exceptiontrap
|
|
134
117
|
defined?(Rails.root) ? Rails.root : Dir.pwd
|
135
118
|
end
|
136
119
|
|
137
|
-
#
|
120
|
+
# TODO: Refactor
|
138
121
|
def normalize_data(hash)
|
139
122
|
new_hash = {}
|
140
123
|
|
141
|
-
# TODO: Do this nicer
|
142
124
|
hash.each do |key, value|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
125
|
+
if value.respond_to?(:to_hash)
|
126
|
+
begin
|
127
|
+
new_hash[key] = normalize_data(value.to_hash)
|
128
|
+
rescue
|
129
|
+
new_hash[key] = value.to_s
|
130
|
+
end
|
149
131
|
else
|
150
132
|
new_hash[key] = value.to_s
|
151
133
|
end
|
@@ -156,4 +138,4 @@ module Exceptiontrap
|
|
156
138
|
|
157
139
|
end
|
158
140
|
end
|
159
|
-
end
|
141
|
+
end
|
data/lib/exceptiontrap/rack.rb
CHANGED
@@ -8,10 +8,11 @@ module Exceptiontrap
|
|
8
8
|
begin
|
9
9
|
response = @app.call(env)
|
10
10
|
rescue Exception => exception
|
11
|
-
puts '[Exceptiontrap] Raised Exceptiontrap::Rack::Exception'
|
12
11
|
puts "[Exceptiontrap] Caught Exception: #{exception.class.name}"
|
12
|
+
|
13
13
|
data = Exceptiontrap::Data.rack_data(exception, env)
|
14
14
|
Exceptiontrap::Notifier.notify(data)
|
15
|
+
|
15
16
|
raise
|
16
17
|
end
|
17
18
|
|
@@ -19,4 +20,4 @@ module Exceptiontrap
|
|
19
20
|
end
|
20
21
|
|
21
22
|
end
|
22
|
-
end
|
23
|
+
end
|
@@ -8,7 +8,7 @@ module Exceptiontrap
|
|
8
8
|
Exceptiontrap::Config.load(File.join(Rails.root, '/config/exceptiontrap.yml'))
|
9
9
|
next if Exceptiontrap::disabled?
|
10
10
|
|
11
|
-
app.config.middleware.insert_after ActionDispatch::
|
11
|
+
app.config.middleware.insert_after ActionDispatch::DebugExceptions, Exceptiontrap::Rack
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/exceptiontrap.rb
CHANGED
@@ -22,12 +22,6 @@ module Exceptiontrap
|
|
22
22
|
'Accept' => 'application/json'
|
23
23
|
}
|
24
24
|
|
25
|
-
def self.notify(exception, params = {})
|
26
|
-
return if disabled?
|
27
|
-
data = Data.rack_data(exception, params)
|
28
|
-
Notifier.notify(data)
|
29
|
-
end
|
30
|
-
|
31
25
|
def self.enabled?
|
32
26
|
Config.enabled_environments.include?(Data.application_environment)
|
33
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exceptiontrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbuehl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|