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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3543194c8dc3ff5474934185936a3e514d347416
4
- data.tar.gz: ef3d398dc36f503b8adaacacd24a0396c187eac6
3
+ metadata.gz: 91ff73c055e4c1842915157c1efa958eb24cfad1
4
+ data.tar.gz: 6e6d5b3070ba4156499b9710c94260a857df5ac0
5
5
  SHA512:
6
- metadata.gz: adc6cf77472d1657f151c4287dba352ceaf5675de5cde8d6d7a9c2801ef4d99967955601b43acf32684f07476f9992117a4ac13d7102ddd02595ba015bf8ce15
7
- data.tar.gz: 5b6c56513e62c187b9871381eba3bde99c9ff71c6c3ab593406c96f434ca33fd85eeb00437af213c6eee4b05dc7fc3c671428cfc7fb14930f99ae6c7d5400823
6
+ metadata.gz: 7ea535f196c3f3964d9b8bd33654e2591637bdd2949ef599d6aed5359b3ade919254d1ff489c0f00108eb780b5b2fb8cd48ae84598fedfa0066de314ceb41acd
7
+ data.tar.gz: cc15c40d7b585a8496e4ba2d12f9681f5a7951b61acee64fc180ffe254b4ec236cbf22335375a41a75c429ec6917d8fe99d95e1bc0310c184f16c40e6f4ee736
@@ -1,3 +1,3 @@
1
1
  module RorVsWild
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.4.1".freeze
3
3
  end
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 = %w[ActionController::RoutingError] + config.action_dispatch.rescue_responses.map { |(key,value)| key }
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 !ignored_exceptions.include?(exception.class.to_s)
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 => exception
189
- job[:error] = exception_to_hash(exception)
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 => exception
202
- record_error(exception, extra_details)
203
- exception
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] "))
@@ -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.0
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-01-27 00:00:00.000000000 Z
11
+ date: 2017-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler