nxt_error_registry 0.1.0 → 0.1.1
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/README.md +6 -2
- data/lib/nxt_error_registry.rb +5 -1
- data/lib/nxt_error_registry/version.rb +1 -1
- data/nxt_error_registry.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14378b65ba8a35439c7e61f30ff29dc3c61380bd34e3dcb8483f1c1c288c0702
|
4
|
+
data.tar.gz: b1ec6d66506ac1a5291e534aa457f212a84e49a83b4b34d1560da8a0c63ccd12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a18195bcbc5f49999acae19eaa291309e23a13ea5183cc81f27a1a1c58f329ec7f773a4c1f600e5f841ce88b7394b642e85e9c7e35da39f8b5448d8d7c8b1c6e
|
7
|
+
data.tar.gz: dad3e3938ab2da06d975280eee4791d9abd5f3bcfbbf2977307763252ec6c27ad29866b478e5532c89ad8d15c4e4e5bd90d4a3070fbfc11e416fbe50a3fdb0ee
|
data/README.md
CHANGED
@@ -24,12 +24,16 @@ Or install it yourself as:
|
|
24
24
|
class LevelOne
|
25
25
|
extend NxtErrorRegistry
|
26
26
|
register_error :LevelOneError, type: StandardError, code: '100.100'
|
27
|
-
# This will set the LevelOne::LevelOneError constant that you can raise anywhere
|
27
|
+
# This will set the LevelOne::LevelOneError constant that you can raise anywhere
|
28
|
+
register_error :LevelTwoError, type: LevelOneError, code: '100.101', capture: true, reraise: false
|
29
|
+
# You can also pass in additional options when registering your errors. These will be available on you error class
|
28
30
|
|
29
31
|
def raise_level_one_error
|
30
32
|
raise LevelOneError, 'There was an error on level'
|
31
33
|
rescue LevelOneError => e
|
32
|
-
puts e.code # would output '100.100'
|
34
|
+
puts e.code # would output '100.100'
|
35
|
+
rescue LevelTwoError => e
|
36
|
+
puts e.options # { capture: true, reraise: false }
|
33
37
|
end
|
34
38
|
end
|
35
39
|
```
|
data/lib/nxt_error_registry.rb
CHANGED
@@ -15,7 +15,11 @@ module NxtErrorRegistry
|
|
15
15
|
|
16
16
|
error_class = Class.new(type, &block)
|
17
17
|
error_class.define_singleton_method :code, -> { code }
|
18
|
-
error_class.define_singleton_method :options
|
18
|
+
error_class.define_singleton_method :options do
|
19
|
+
# the superclass "type" may not have defined options yet
|
20
|
+
inherited_options = type.try(:options) || {}
|
21
|
+
inherited_options.merge(opts)
|
22
|
+
end
|
19
23
|
|
20
24
|
const_set(name, error_class)
|
21
25
|
entry = { code: code, error_class: error_class, type: type, name: name, namespace: self.to_s, opts: opts }
|
data/nxt_error_registry.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
21
21
|
|
22
22
|
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
-
spec.metadata["source_code_uri"] = "https://github.com/nxt-insurance/
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/nxt-insurance/nxt_error_registry"
|
24
24
|
else
|
25
25
|
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
26
|
"public gem pushes."
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nxt_error_registry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Robecke
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-03-
|
13
|
+
date: 2019-03-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -128,7 +128,7 @@ licenses:
|
|
128
128
|
metadata:
|
129
129
|
allowed_push_host: https://rubygems.org
|
130
130
|
homepage_uri: https://github.com/nxt-insurance
|
131
|
-
source_code_uri: https://github.com/nxt-insurance/
|
131
|
+
source_code_uri: https://github.com/nxt-insurance/nxt_error_registry
|
132
132
|
post_install_message:
|
133
133
|
rdoc_options: []
|
134
134
|
require_paths:
|