escalate 0.2.0.pre.1 → 0.2.0.pre.2
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/lib/escalate.rb +7 -17
- data/lib/escalate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e6dc6ba580b590c324c351001687805582d7a2d757cb7aebeaed1a6ee50d07b
|
4
|
+
data.tar.gz: '02439935ba7a19a8c68b5ff0adcad892d658b29a2f843311a79a798fa090fac2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d9cb26ed59b9eca7f0a234ed2ead5375ae2144128098b6cd74bbabe54cdd6281278baaf12cf186a4873c9bf50092f5440e4e10931da33f606bca344f76edd6
|
7
|
+
data.tar.gz: d9608ff9899f52a7a99a2e26937340b3909d4715e9f5dbd68bdb7474fbe2782c7419f277ef3ab3d21d931a4fa9ad656b877929796707003fb01b771e8910370f
|
data/Gemfile.lock
CHANGED
data/lib/escalate.rb
CHANGED
@@ -9,6 +9,8 @@ require_relative "escalate/mixin"
|
|
9
9
|
module Escalate
|
10
10
|
class Error < StandardError; end
|
11
11
|
|
12
|
+
LOG_FIRST_INSTANCE_VARIABLE = :@_escalate_log_first
|
13
|
+
|
12
14
|
class << self
|
13
15
|
# Logs and escalated an exception
|
14
16
|
#
|
@@ -25,7 +27,7 @@ module Escalate
|
|
25
27
|
# Any additional context to be tied to the escalation
|
26
28
|
def escalate(exception, location_message, logger, **context)
|
27
29
|
ensure_failsafe("Exception rescued while escalating #{exception.inspect}") do
|
28
|
-
if on_escalate_blocks.
|
30
|
+
if on_escalate_blocks.none? || on_escalate_blocks.any? { |block| block.instance_variable_get(LOG_FIRST_INSTANCE_VARIABLE) }
|
29
31
|
error_message = <<~EOS
|
30
32
|
[Escalate] #{location_message} (#{context.inspect})
|
31
33
|
#{exception.class.name}: #{exception.message}
|
@@ -39,7 +41,7 @@ module Escalate
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
42
|
-
|
44
|
+
on_escalate_blocks.each do |block|
|
43
45
|
ensure_failsafe("Exception rescued while escalating #{exception.inspect} to #{block.inspect}") do
|
44
46
|
block.call(exception, location_message, **context)
|
45
47
|
end
|
@@ -87,16 +89,12 @@ module Escalate
|
|
87
89
|
# @param [boolean] log_first: true
|
88
90
|
# whether escalate should log first before escalating, or leave the logging to the escalate block
|
89
91
|
def on_escalate(log_first: true, &block)
|
90
|
-
|
91
|
-
|
92
|
-
else
|
93
|
-
on_escalate_no_log_first_blocks.add(block)
|
94
|
-
end
|
92
|
+
block.instance_variable_set(LOG_FIRST_INSTANCE_VARIABLE, log_first)
|
93
|
+
on_escalate_blocks.add(block)
|
95
94
|
end
|
96
95
|
|
97
|
-
def
|
96
|
+
def clear_on_escalate_callbacks
|
98
97
|
on_escalate_blocks.clear
|
99
|
-
on_escalate_no_log_first_blocks.clear
|
100
98
|
end
|
101
99
|
|
102
100
|
private
|
@@ -115,13 +113,5 @@ module Escalate
|
|
115
113
|
def on_escalate_blocks
|
116
114
|
@on_escalate_blocks ||= Set.new
|
117
115
|
end
|
118
|
-
|
119
|
-
def on_escalate_no_log_first_blocks
|
120
|
-
@on_escalate_no_log_first_blocks ||= Set.new
|
121
|
-
end
|
122
|
-
|
123
|
-
def all_on_escalate_blocks
|
124
|
-
on_escalate_blocks + on_escalate_no_log_first_blocks
|
125
|
-
end
|
126
116
|
end
|
127
117
|
end
|
data/lib/escalate/version.rb
CHANGED