exception_notification_moderate 0.0.2 → 0.0.3

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: 23b3a5fe475a9a0b6f1d21f96690fd2e46867391
4
- data.tar.gz: 03c22ea2d71fb47f920351d5f807714a6777cd23
3
+ metadata.gz: e20a0eaf3ea67c0d3113ec14b2be957442f93df6
4
+ data.tar.gz: fcb57ad5190691dc3adb0c3abeb8976fe64074ac
5
5
  SHA512:
6
- metadata.gz: f99851e321960f1ab9f7db595dbd71dc93a5952ed616002a9548a25268c6f91f0d5759ec0a751995cc30bf744829d6a074f01c3efe8d6fa637b2692ce19ee736
7
- data.tar.gz: 7a5391de76bd6c6dab0c3b5190ccdb9b489308dae1420c2619b44e9ac9e0ff70e96732d1aba2970af896c0fce895cf4a6308ecad7a8b3f8c7f6e067f70c99852
6
+ metadata.gz: c1bc9ca04a5c433266d547eaa6bfacdd6e8bd01ac504d882ad2f27c1aa53a1836f9b5d3352d42eb5c4320c15b350b174256778461d6b95c87baef2c338753ef5
7
+ data.tar.gz: 0f2b84471d4f96ba8a60f19857260d805c23787413a1e99c6609fa727c21cdc99c7e0968bc182e655e56d8b99742c0a4492a428b04cf367ae3c94d1cd54164ae
@@ -7,20 +7,15 @@ module ExceptionNotifier
7
7
 
8
8
  def notify_exception(exception, options={})
9
9
  ex_key = exception_key(exception)
10
- begin
11
- val = redis.get(ex_key)
12
- rescue Redis::CannotConnectError
13
- end
10
+
11
+ val = execute_with_rescue_error { redis.get(ex_key) }
14
12
  if val && val.to_i + 60 > Time.now.to_i
15
13
  # Write log and return.
16
14
  ExceptionNotificationModerate.logger.info(exception)
17
15
  return false
18
16
  end
19
17
 
20
- begin
21
- redis.set(ex_key, Time.now.to_i)
22
- rescue Redis::CannotConnectError
23
- end
18
+ execute_with_rescue_error { redis.set(ex_key, Time.now.to_i) }
24
19
  original_notify_exception(exception, options)
25
20
  end
26
21
 
@@ -30,6 +25,11 @@ module ExceptionNotifier
30
25
  "#{exception.to_s}_#{exception.message}"
31
26
  end
32
27
 
28
+ def execute_with_rescue_error
29
+ yield
30
+ rescue Redis::CannotConnectError, SocketError
31
+ end
32
+
33
33
  def redis
34
34
  if ExceptionNotificationModerate.redis_host
35
35
  Redis.new(host: ExceptionNotificationModerate.redis_host)
@@ -1,3 +1,3 @@
1
1
  module ExceptionNotificationModerate
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification_moderate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryonext