openstax_rescue_from 4.2.1 → 4.3.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
  SHA256:
3
- metadata.gz: ec7e531f87626b3a0350e50d5dbaf70d3cedeecc3ead54e8e105d666e10bfb83
4
- data.tar.gz: 015355dbb7bee67cddf2c96e02f368a993d787913488692605c4b894757dfa8e
3
+ metadata.gz: 7811c87dc161137cbab9aba396a25048b86ffd57972bf598459be4d0716c3afc
4
+ data.tar.gz: 323f38b60624ab56040a79df5e7b826367269f59f5c9bef5b468833407991f9c
5
5
  SHA512:
6
- metadata.gz: fcf93a6ba12f2cc75dc3856b0b81726950b1ca2240acbf161a8d6c7c209bae7aa93dc5d02ba3c6846ca75a8147344c1e01eb97617a4bef1def2c1255d58e34b0
7
- data.tar.gz: 693f1ad77e81262bd7e2a8c80a64342efcd308c31f4362d315ba4e23ba3468bddd99da45845685098f99b9894d315d06b05f9cf709ee08d0d45ef37b473a5908
6
+ metadata.gz: ac77b65135b03d1c70bc8a8f3c4b2b461575649e0dc0fb8dbb4fd52e10be973deaa3fb47ab43f021855b407cc2320392292b103032ad7b3fbb7424142943219e
7
+ data.tar.gz: d86e42d01992770066292d4258c568ad2dbaab5169ce567fa7899d84cca71973831b2995fc5add50853e4831c15cc5b4255cf076737d64652055ef07c068111c
data/README.md CHANGED
@@ -62,19 +62,6 @@ OpenStax::RescueFrom.register_exception(SecurityTransgression, status: 403,
62
62
 
63
63
  OpenStax::RescueFrom.register_exception('ActiveRecord::RecordNotFound', notify: false,
64
64
  status: 404)
65
-
66
- # Use OpenStax::RescueFrom.register_unrecognized_exception(exception_constant_or_string, options = {})
67
- # to register ONLY unrecognized exceptions, to avoid accidental overwriting of options
68
-
69
- OpenStax::RescueFrom.register_unrecognized_exception(SecurityTransgression)
70
-
71
- # when used with example above, the above example's options will prevail
72
-
73
- # Default options:
74
- #
75
- # { notify: true,
76
- # status: :internal_server_error,
77
- # extras: ->(exception) { {} } }
78
65
  ```
79
66
 
80
67
  **Note:** If you want to define `extras`, you **must** use a function that accepts `exception` as its argument
@@ -19,7 +19,6 @@ module OpenStax
19
19
  private
20
20
  def record_system_error_recursively!
21
21
  if exception_proxy.cause
22
- RescueFrom.register_exception(exception_proxy.cause.class)
23
22
  @exception_proxy = ExceptionCauseProxy.new(exception_proxy.cause)
24
23
  record_system_error!("Exception cause")
25
24
  end
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module RescueFrom
3
- VERSION = '4.2.1'
3
+ VERSION = '4.3.0'
4
4
  end
5
5
  end
@@ -9,7 +9,6 @@ module OpenStax
9
9
  class << self
10
10
  def perform_rescue(exception, listener = MuteListener.new)
11
11
  proxy = ExceptionProxy.new(exception)
12
- register_unrecognized_exception(proxy.name)
13
12
  log_system_error(proxy)
14
13
  send_notifying_exceptions(proxy, listener)
15
14
  finish_exception_rescue(proxy, listener)
@@ -17,7 +16,6 @@ module OpenStax
17
16
 
18
17
  def perform_background_rescue(exception, listener = MuteListener.new)
19
18
  proxy = ExceptionProxy.new(exception)
20
- register_unrecognized_exception(proxy.name)
21
19
  log_background_system_error(proxy)
22
20
  send_notifying_background_exceptions(proxy)
23
21
  finish_background_exception_rescue(proxy, listener)
@@ -44,12 +42,6 @@ module OpenStax
44
42
  @@registered_exceptions[name] = options
45
43
  end
46
44
 
47
- def register_unrecognized_exception(exception_class, options = {})
48
- unless registered_exceptions.keys.include?(exception_class)
49
- register_exception(exception_class, options)
50
- end
51
- end
52
-
53
45
  # For rescuing from specific blocks of code: OpenStax::RescueFrom.this {...}
54
46
  def this(background = true)
55
47
  begin
@@ -84,15 +76,15 @@ module OpenStax
84
76
  end
85
77
 
86
78
  def notifies_for?(exception_name)
87
- notifying_exceptions.include?(exception_name)
79
+ options_for(exception_name).notify?
88
80
  end
89
81
 
90
82
  def status(exception_name)
91
- @@registered_exceptions[exception_name].status_code
83
+ options_for(exception_name).status_code
92
84
  end
93
85
 
94
86
  def sorry(exception_name)
95
- @@registered_exceptions[exception_name].sorry
87
+ options_for(exception_name).sorry
96
88
  end
97
89
 
98
90
  def http_code(status)
@@ -100,7 +92,7 @@ module OpenStax
100
92
  end
101
93
 
102
94
  def extras_proc(exception_name)
103
- @@registered_exceptions[exception_name].extras
95
+ options_for(exception_name).extras
104
96
  end
105
97
 
106
98
  def generate_id
@@ -116,8 +108,9 @@ module OpenStax
116
108
  end
117
109
 
118
110
  private
111
+
119
112
  def options_for(name)
120
- @@registered_exceptions[name]
113
+ @@registered_exceptions[name] || ExceptionOptions.new
121
114
  end
122
115
 
123
116
  def friendly_status_messages
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: 4.2.1
4
+ version: 4.3.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: 2024-10-09 00:00:00.000000000 Z
12
+ date: 2024-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails