nxt_error_registry 0.1.0 → 0.1.1

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: 1416b01c67cb9983abfddad361cc89b8c4def0493a7ef77814ed938708070439
4
- data.tar.gz: 45ae14a632c3400ffdc01f626a4313ba141850c3ef8ea23746e025bf0782383e
3
+ metadata.gz: 14378b65ba8a35439c7e61f30ff29dc3c61380bd34e3dcb8483f1c1c288c0702
4
+ data.tar.gz: b1ec6d66506ac1a5291e534aa457f212a84e49a83b4b34d1560da8a0c63ccd12
5
5
  SHA512:
6
- metadata.gz: af1e86ac007ab52f8720d6707233d6853acb5f53565ff14e660fe153f27e768ae7bfb8a48a04a63a4220e84ba460b65933dd2fcc5e7ece080af008bfde491cf1
7
- data.tar.gz: 772c4a08c6db03a3d9e69147e4788becb91fd2c727a567807a9ac0881107b1c96d3454090c74a43a84d4f4ce72a186b9ca0ce1023bfa26cbb22a16761d56012b
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
  ```
@@ -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, -> { opts }
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 }
@@ -1,3 +1,3 @@
1
1
  module NxtErrorRegistry
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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/nxt_init"
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.0
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-25 00:00:00.000000000 Z
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/nxt_init
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: