rescue_registry 0.2.3 → 1.0.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 +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +1 -0
- data/Rakefile +6 -1
- data/lib/rescue_registry/exception_handler.rb +15 -8
- data/lib/rescue_registry/version.rb +1 -1
- data/lib/rescue_registry.rb +12 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3575942ac21357ea65531cb89bf233d75a2dc983d220f279cc5c5ebac0c6c3be
|
4
|
+
data.tar.gz: c3c3a52aa8fe8ed34d66fe0b03062282793a24c0df69c456ef92afca1e0e7f8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add3e437decc5c77801e74e2a1d3f5330122a142578c6133e57eae884d638323e35a984dcbcfa0e6e3845d21680675e08a0f5f0d82e4f4cfec8afacb76e08842
|
7
|
+
data.tar.gz: 50dc6cc1cdb148cc22590b1854f9f6d285c6a7a693ad4b4fc4e6711e2058632854aad07d0b118e7a0231d514241616faea48296b6c707be71222586e3249c2e2
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
---
|
9
9
|
|
10
|
+
## [1.0.0] - 2022-02-03
|
11
|
+
### Changed
|
12
|
+
- Removed upper version bound to support Ruby 3.1. (thanks @nulldotpro)
|
13
|
+
|
14
|
+
## [0.3.0] - 2021-05-11
|
15
|
+
### Changed
|
16
|
+
- For better JSONAPI spec compliance, errors payloads will not include the `details` key when value is `null`.
|
17
|
+
- Error payloads will not include the `meta` key when value is an empty object.
|
18
|
+
|
19
|
+
## [0.2.5] - 2021-03-09
|
20
|
+
### Added
|
21
|
+
- `code` can now be provided as an argument to `register_exception` - #29 (thanks @amaierhofer)
|
22
|
+
|
23
|
+
## [0.2.4] - 2021-01-22
|
24
|
+
### Fixed
|
25
|
+
- Support Ruby 3 (thanks @zvkemp and @ef4)
|
26
|
+
|
10
27
|
## [0.2.3] - 2020-09-01
|
11
28
|
### Fixed
|
12
29
|
- Properly handle exceptions for invalid format types - #25 (thanks @shanet)
|
data/README.md
CHANGED
@@ -58,6 +58,7 @@ class MyController < ActionController::Base
|
|
58
58
|
register_exception MetaProcError, meta: -> (e) { { class_name: e.class.name.upcase } }
|
59
59
|
register_exception CustomHandlerError, handler: CustomErrorHandler
|
60
60
|
register_exception RailsError, status: 403, handler: RescueRegistry::RailsExceptionHandler
|
61
|
+
register_exception CustomStatusError, status: 422, code: :name_invalid
|
61
62
|
end
|
62
63
|
```
|
63
64
|
|
data/Rakefile
CHANGED
@@ -4,6 +4,7 @@ rescue LoadError
|
|
4
4
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
5
|
end
|
6
6
|
|
7
|
+
require 'rails/version'
|
7
8
|
require 'yard'
|
8
9
|
require 'rspec/core/rake_task'
|
9
10
|
require 'bundler/gem_tasks'
|
@@ -14,7 +15,11 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
14
15
|
t.rspec_opts = "--order random"
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
+
if Rails::VERSION::MAJOR < 7
|
19
|
+
APP_RAKEFILE = File.expand_path("spec/rails5/dummy/Rakefile", __dir__)
|
20
|
+
else
|
21
|
+
APP_RAKEFILE = File.expand_path("spec/rails7/dummy/Rakefile", __dir__)
|
22
|
+
end
|
18
23
|
load "rails/tasks/engine.rake"
|
19
24
|
|
20
25
|
task default: :spec
|
@@ -21,6 +21,7 @@ module RescueRegistry
|
|
21
21
|
end
|
22
22
|
|
23
23
|
@meta = options[:meta]
|
24
|
+
@code = options[:code]
|
24
25
|
|
25
26
|
# TODO: Warn about unrecognized options
|
26
27
|
end
|
@@ -29,7 +30,7 @@ module RescueRegistry
|
|
29
30
|
alias_method :status_code, :status
|
30
31
|
|
31
32
|
def error_code
|
32
|
-
error_code_from_status
|
33
|
+
@code.presence || error_code_from_status
|
33
34
|
end
|
34
35
|
|
35
36
|
def title
|
@@ -74,14 +75,20 @@ module RescueRegistry
|
|
74
75
|
)
|
75
76
|
end
|
76
77
|
|
78
|
+
error_payload = {
|
79
|
+
code: error_code,
|
80
|
+
status: status_code.to_s,
|
81
|
+
title: title
|
82
|
+
}
|
83
|
+
|
84
|
+
if (d = detail)
|
85
|
+
error_payload[:detail] = d
|
86
|
+
end
|
87
|
+
|
88
|
+
error_payload[:meta] = payload_meta if payload_meta.any?
|
89
|
+
|
77
90
|
{
|
78
|
-
errors: [
|
79
|
-
code: error_code,
|
80
|
-
status: status_code.to_s,
|
81
|
-
title: title,
|
82
|
-
detail: detail,
|
83
|
-
meta: payload_meta
|
84
|
-
]
|
91
|
+
errors: [error_payload]
|
85
92
|
}
|
86
93
|
end
|
87
94
|
|
data/lib/rescue_registry.rb
CHANGED
@@ -46,6 +46,18 @@ module RescueRegistry
|
|
46
46
|
context.rescue_registry.public_send(method, *args)
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
# the Module#ruby2_keywords is added starting at ruby 2.7. It lets us mark
|
51
|
+
# these methods as using ruby2-style keyword argument semantics. This will
|
52
|
+
# keep them working correctly on ruby3, and clears a deprecation that
|
53
|
+
# otherwise fires in 2.7+.
|
54
|
+
if respond_to?(:ruby2_keywords, true)
|
55
|
+
class << self
|
56
|
+
REGISTRY_METHODS.each do |method|
|
57
|
+
ruby2_keywords(method)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
49
61
|
end
|
50
62
|
|
51
63
|
ActiveSupport.on_load(:before_initialize) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rescue_registry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Wagenet
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.9'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- peter.wagenet@gmail.com
|
86
86
|
executables: []
|
@@ -114,13 +114,13 @@ metadata:
|
|
114
114
|
bug_tracker_uri: https://github.com/wagenet/rescue_registry/issues
|
115
115
|
changelog_uri: https://github.com/wagenet/rescue_registry/CHANGELOG.md
|
116
116
|
source_code_uri: https://github.com/wagenet/rescue_registry
|
117
|
-
post_install_message:
|
117
|
+
post_install_message:
|
118
118
|
rdoc_options: []
|
119
119
|
require_paths:
|
120
120
|
- lib
|
121
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '2.3'
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -129,8 +129,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
133
|
-
signing_key:
|
132
|
+
rubygems_version: 3.3.3
|
133
|
+
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Registry for Rails Exceptions
|
136
136
|
test_files: []
|