rorvswild 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rorvswild/version.rb +1 -1
- data/lib/rorvswild.rb +11 -7
- data/test/ror_vs_wild_test.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91ff73c055e4c1842915157c1efa958eb24cfad1
|
4
|
+
data.tar.gz: 6e6d5b3070ba4156499b9710c94260a857df5ac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ea535f196c3f3964d9b8bd33654e2591637bdd2949ef599d6aed5359b3ade919254d1ff489c0f00108eb780b5b2fb8cd48ae84598fedfa0066de314ceb41acd
|
7
|
+
data.tar.gz: cc15c40d7b585a8496e4ba2d12f9681f5a7951b61acee64fc180ffe254b4ec236cbf22335375a41a75c429ec6917d8fe99d95e1bc0310c184f16c40e6f4ee736
|
data/lib/rorvswild/version.rb
CHANGED
data/lib/rorvswild.rb
CHANGED
@@ -84,7 +84,7 @@ module RorVsWild
|
|
84
84
|
@app_root ||= Rails.root.to_s
|
85
85
|
config = Rails.application.config
|
86
86
|
@parameter_filter = ActionDispatch::Http::ParameterFilter.new(config.filter_parameters)
|
87
|
-
@ignored_exceptions
|
87
|
+
@ignored_exceptions ||= %w[ActionController::RoutingError] + config.action_dispatch.rescue_responses.map { |(key,value)| key }
|
88
88
|
end
|
89
89
|
|
90
90
|
@logger ||= Logger.new(STDERR)
|
@@ -150,7 +150,7 @@ module RorVsWild
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def after_exception(exception, controller)
|
153
|
-
if !
|
153
|
+
if !ignored_exception?(exception)
|
154
154
|
file, line = exception.backtrace.first.split(":")
|
155
155
|
request[:error] = exception_to_hash(exception).merge(
|
156
156
|
session: controller.session.to_hash,
|
@@ -185,8 +185,8 @@ module RorVsWild
|
|
185
185
|
cpu_time_offset = cpu_time
|
186
186
|
begin
|
187
187
|
block.call
|
188
|
-
rescue Exception =>
|
189
|
-
job[:error] = exception_to_hash(
|
188
|
+
rescue Exception => ex
|
189
|
+
job[:error] = exception_to_hash(ex) if !ignored_exception?(ex)
|
190
190
|
raise
|
191
191
|
ensure
|
192
192
|
job[:runtime] = (Time.now - started_at) * 1000
|
@@ -198,9 +198,9 @@ module RorVsWild
|
|
198
198
|
def catch_error(extra_details = nil, &block)
|
199
199
|
begin
|
200
200
|
block.call
|
201
|
-
rescue Exception =>
|
202
|
-
record_error(
|
203
|
-
|
201
|
+
rescue Exception => ex
|
202
|
+
record_error(ex, extra_details) if !ignored_exception?(ex)
|
203
|
+
ex
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -385,6 +385,10 @@ module RorVsWild
|
|
385
385
|
hash.clone.keep_if { |key,value| key == key.upcase }
|
386
386
|
end
|
387
387
|
|
388
|
+
def ignored_exception?(exception)
|
389
|
+
ignored_exceptions.include?(exception.class.to_s)
|
390
|
+
end
|
391
|
+
|
388
392
|
def log_error(exception)
|
389
393
|
@logger.error("[RorVsWild] " + exception.inspect)
|
390
394
|
@logger.error("[RorVsWild] " + exception.backtrace.join("\n[RorVsWild] "))
|
data/test/ror_vs_wild_test.rb
CHANGED
@@ -27,6 +27,13 @@ class RorVsWildTest < Minitest::Test
|
|
27
27
|
assert(client.send(:job)[:error])
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_mesure_block_when_exception_is_ignored
|
31
|
+
client = initialize_client(ignored_exceptions: %w[ZeroDivisionError])
|
32
|
+
client.expects(:post_job)
|
33
|
+
assert_raises(ZeroDivisionError) { RorVsWild.measure_code("1/0") }
|
34
|
+
refute(client.send(:job)[:error])
|
35
|
+
end
|
36
|
+
|
30
37
|
def test_measure_code_when_no_client
|
31
38
|
RorVsWild.register_default_client(nil)
|
32
39
|
RorVsWild::Client.any_instance.expects(:post_job).never
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|