openstax_rescue_from 2.0.1 → 2.1.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f56fb3c7bf8ded13176b734d53f1fe4c8342abf0
|
4
|
+
data.tar.gz: 67d6bad535a4d2dec26bbacc82f1fe7e9c2b6c55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bb963a69ecd726c5971ff26c665b172e2aa859abb1d3790111036d96c70b9ac62730dc09881e5c1001c3ae8bfab80ffffc8daaa7cfc96b7fef51d4b8c364823
|
7
|
+
data.tar.gz: a805ae5d1c5e446fbf3aa519b27127e2b3a9f94a14d2fca32d0ad0ff1ec1cee7ed588aa37c5ecd186a91fba63e3a2e0b04092ee986be178eb2fcfb5f94f0331d
|
@@ -3,6 +3,9 @@ require 'openstax_rescue_from'
|
|
3
3
|
OpenStax::RescueFrom.configure do |config|
|
4
4
|
config.raise_exceptions = ![false, 'false'].include?(ENV['RAISE_EXCEPTIONS']) ||
|
5
5
|
Rails.application.config.consider_all_requests_local
|
6
|
+
config.raise_background_exceptions = ![false, 'false'].include?(
|
7
|
+
ENV['RAISE_BACKGROUND_EXCEPTIONS']
|
8
|
+
)
|
6
9
|
|
7
10
|
# config.app_name = ENV['APP_NAME']
|
8
11
|
# config.app_env = ENV['APP_ENV']
|
data/lib/openstax/rescue_from.rb
CHANGED
@@ -15,21 +15,25 @@ module OpenStax
|
|
15
15
|
finish_exception_rescue(proxy, listener)
|
16
16
|
end
|
17
17
|
|
18
|
-
def perform_background_rescue(exception)
|
18
|
+
def perform_background_rescue(exception, listener = MuteListener.new)
|
19
19
|
proxy = ExceptionProxy.new(exception)
|
20
20
|
register_unrecognized_exception(proxy.name)
|
21
21
|
log_background_system_error(proxy)
|
22
22
|
send_notifying_background_exceptions(proxy)
|
23
|
-
finish_background_exception_rescue(proxy)
|
23
|
+
finish_background_exception_rescue(proxy, listener)
|
24
24
|
end
|
25
25
|
|
26
|
+
# Not threadsafe
|
26
27
|
def do_not_reraise
|
27
28
|
original = configuration.raise_exceptions
|
29
|
+
original_background = configuration.raise_background_exceptions
|
28
30
|
begin
|
29
31
|
configuration.raise_exceptions = false
|
32
|
+
configuration.raise_background_exceptions = false
|
30
33
|
yield
|
31
34
|
ensure
|
32
35
|
configuration.raise_exceptions = original
|
36
|
+
configuration.raise_background_exceptions = original_background
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
@@ -46,12 +50,12 @@ module OpenStax
|
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
# For rescuing from specific blocks of code: OpenStax::RescueFrom.this{...}
|
50
|
-
def this
|
53
|
+
# For rescuing from specific blocks of code: OpenStax::RescueFrom.this {...}
|
54
|
+
def this(background = true)
|
51
55
|
begin
|
52
56
|
yield
|
53
|
-
rescue Exception =>
|
54
|
-
perform_rescue(
|
57
|
+
rescue Exception => ex
|
58
|
+
background ? perform_background_rescue(ex) : perform_rescue(ex)
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
@@ -190,8 +194,12 @@ module OpenStax
|
|
190
194
|
end
|
191
195
|
end
|
192
196
|
|
193
|
-
def finish_background_exception_rescue(proxy)
|
194
|
-
|
197
|
+
def finish_background_exception_rescue(proxy, listener)
|
198
|
+
if configuration.raise_background_exceptions
|
199
|
+
raise proxy.exception
|
200
|
+
else
|
201
|
+
listener.openstax_exception_rescued(proxy, notifies_for?(proxy.name))
|
202
|
+
end
|
195
203
|
end
|
196
204
|
end
|
197
205
|
end
|
@@ -4,9 +4,9 @@ module OpenStax
|
|
4
4
|
module RescueFrom
|
5
5
|
class Configuration
|
6
6
|
|
7
|
-
attr_accessor :raise_exceptions, :
|
8
|
-
:
|
9
|
-
:email_prefix, :sender_address, :exception_recipients
|
7
|
+
attr_accessor :raise_exceptions, :raise_background_exceptions, :notifier,
|
8
|
+
:html_error_template_path, :html_error_template_layout_name, :app_name,
|
9
|
+
:app_env, :email_prefix, :sender_address, :exception_recipients
|
10
10
|
|
11
11
|
attr_writer :contact_name
|
12
12
|
|
@@ -16,6 +16,9 @@ module OpenStax
|
|
16
16
|
|
17
17
|
def initialize
|
18
18
|
@raise_exceptions = ![false, 'false'].include?(ENV['RAISE_EXCEPTIONS'])
|
19
|
+
@raise_background_exceptions = ![false, 'false'].include?(
|
20
|
+
ENV['RAISE_BACKGROUND_EXCEPTIONS']
|
21
|
+
)
|
19
22
|
|
20
23
|
@app_name = ENV['APP_NAME']
|
21
24
|
@app_env = ENV['APP_ENV']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_rescue_from
|
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
|
- JP Slavinsky
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-10-
|
12
|
+
date: 2017-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|