openstax_rescue_from 1.5.0 → 1.6.0
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
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGVlN2JjZTk3NGUxZDVmOTQwMDRiMDY3Y2IyMzhlZGRlYWVhYTE1OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTc5MDA1MWMyMGJlYzdlMzliODczMzNjYjUyNzg2ZmFmZjc4MjhkYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTc1M2UxMzQxMDAxNTc3YmMyZTU2MzY5Yzg0YTU3NTAwZWFmYWQxMTcwMTA0
|
10
|
+
YWQ3NTVjZDVjMjE0Y2Q5YTM5MTEyMmM2ZjlmOTI0YzM3ODg4ZDAxYTA4MmY2
|
11
|
+
ZTcxZWIzNjUxZGQ0YzI3YjVhZDQyZDE4OWFkNjBlMzI4ZjE0Yzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDY0MDFlMTBhYmYyN2NjNGM2ZWRmMTU2YTM0MDU3YTJjYWI2OGRmYzE4N2U3
|
14
|
+
OGIwNjU2MzMwZDA0NDUwZmEyMTA3OWM3Mjg3YmJlZDVhY2JhYWY3N2JhMTA4
|
15
|
+
ZGQ2ODU4NWMyODNkMDkxYTFiM2IwYmViZWI4Mjc5ZDE4MDRlMTE=
|
@@ -1,16 +1,18 @@
|
|
1
1
|
module OpenStax
|
2
2
|
module RescueFrom
|
3
3
|
class ExceptionOptions
|
4
|
-
attr_accessor :notify, :status_code, :extras
|
4
|
+
attr_accessor :notify, :status_code, :message, :extras
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
options.stringify_keys!
|
8
8
|
options = { 'notify' => true,
|
9
9
|
'status' => :internal_server_error,
|
10
|
+
'message' => nil,
|
10
11
|
'extras' => ->(exception) { {} } }.merge(options)
|
11
12
|
|
12
13
|
@notify = options['notify']
|
13
14
|
@status_code = options['status']
|
15
|
+
@message = options['message']
|
14
16
|
@extras = options['extras']
|
15
17
|
end
|
16
18
|
|
data/lib/openstax/rescue_from.rb
CHANGED
@@ -16,8 +16,9 @@ module OpenStax
|
|
16
16
|
|
17
17
|
def register_exception(exception, options = {})
|
18
18
|
name = exception.is_a?(String) ? exception : exception.name
|
19
|
+
options = ExceptionOptions.new(options)
|
19
20
|
@@registered_exceptions ||= {}
|
20
|
-
@@registered_exceptions[name] =
|
21
|
+
@@registered_exceptions[name] = options
|
21
22
|
end
|
22
23
|
|
23
24
|
def register_unrecognized_exception(exception_class, options = {})
|
@@ -44,8 +45,10 @@ module OpenStax
|
|
44
45
|
@@registered_exceptions.select { |_, v| v.notify? }.keys
|
45
46
|
end
|
46
47
|
|
47
|
-
def friendly_message(
|
48
|
-
|
48
|
+
def friendly_message(proxy)
|
49
|
+
options_for(proxy.name).message ||
|
50
|
+
friendly_status_messages[proxy.status] ||
|
51
|
+
default_friendly_message
|
49
52
|
end
|
50
53
|
|
51
54
|
def notifies_for?(exception_name)
|
@@ -77,6 +80,10 @@ module OpenStax
|
|
77
80
|
end
|
78
81
|
|
79
82
|
private
|
83
|
+
def options_for(name)
|
84
|
+
@@registered_exceptions[name]
|
85
|
+
end
|
86
|
+
|
80
87
|
def friendly_status_messages
|
81
88
|
@@friendly_status_messages ||= {
|
82
89
|
internal_server_error: default_friendly_message,
|
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: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|