jsonapi_errors_handler 0.5.0 → 0.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 +4 -4
- data/.github/workflows/gem-push.yml +11 -8
- data/.github/workflows/gem-test.yml +23 -8
- data/Gemfile.lock +10 -6
- data/README.md +4 -3
- data/lib/jsonapi_errors_handler/errors/invalid.rb +1 -1
- data/lib/jsonapi_errors_handler/errors/standard_error.rb +1 -1
- data/lib/jsonapi_errors_handler/version.rb +1 -1
- data/package-lock.json +3033 -672
- data/package.json +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55c2d748b194dae4550d9d144eaea9f160963bf8773899edd3740490a4d5b57a
|
4
|
+
data.tar.gz: 2210cb76b5c6ed56679b4400565ff4f22e010d0a32d07a88569613cb988bcbb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 924c83974e1c29171cb43bda43cd666e12dcfb9711e33ade5743d22c06f8b3a1b2702871e3b3c4cb85fa15970040d1899950a3cd7cd8e6f0fd95a56cf23cf953
|
7
|
+
data.tar.gz: 4120713b9650d84d940697d8efaf85f49183e2e5fdcbf64b3e3a7a25f57f92398d4a79e115fc4c8baff0cd28428a0eec198997fb89ea9b526f3506fca58103de
|
@@ -7,18 +7,21 @@ on:
|
|
7
7
|
jobs:
|
8
8
|
build:
|
9
9
|
name: Build + Publish
|
10
|
-
|
11
|
-
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
14
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
15
|
+
ruby: [2.7]
|
16
|
+
runs-on: ${{ matrix.os }}
|
12
17
|
steps:
|
13
18
|
- uses: actions/checkout@v2
|
14
|
-
-
|
15
|
-
uses: actions/setup-ruby@v1
|
19
|
+
- uses: ruby/setup-ruby@v1
|
16
20
|
with:
|
17
|
-
ruby-version:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
18
23
|
- name: Run tests
|
19
|
-
run:
|
20
|
-
bundle install
|
21
|
-
bundle exec rspec
|
24
|
+
run: CI=true bundle exec rspec
|
22
25
|
- name: Publish to RubyGems
|
23
26
|
run: |
|
24
27
|
mkdir -p $HOME/.gem
|
@@ -9,18 +9,33 @@ on:
|
|
9
9
|
jobs:
|
10
10
|
build:
|
11
11
|
name: Build + Test
|
12
|
-
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu-latest, macos-latest]
|
15
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
16
|
+
ruby:
|
17
|
+
- 2.7
|
18
|
+
- '3.0'
|
19
|
+
- 3.1
|
20
|
+
- head
|
21
|
+
- truffleruby
|
22
|
+
- truffleruby-head
|
23
|
+
# - jruby
|
24
|
+
# - jruby-head
|
25
|
+
runs-on: ${{ matrix.os }}
|
26
|
+
permissions:
|
27
|
+
contents: read
|
28
|
+
packages: write
|
13
29
|
|
14
30
|
steps:
|
15
|
-
- uses: actions/checkout@
|
16
|
-
- name:
|
17
|
-
uses:
|
31
|
+
- uses: actions/checkout@v3
|
32
|
+
- name: Setup Ruby versions
|
33
|
+
uses: ruby/setup-ruby@v1
|
18
34
|
with:
|
19
|
-
ruby-version:
|
35
|
+
ruby-version: ${{ matrix.ruby }}
|
36
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
20
37
|
- name: Run tests
|
21
|
-
run:
|
22
|
-
bundle install
|
23
|
-
CI=true bundle exec rspec
|
38
|
+
run: CI=true bundle exec rspec
|
24
39
|
- name: Upload report
|
25
40
|
run: |
|
26
41
|
mv ./coverage/coverage.xml cobertura.xml
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jsonapi_errors_handler (0.
|
4
|
+
jsonapi_errors_handler (0.6.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.4.4)
|
10
|
-
docile (1.
|
10
|
+
docile (1.4.0)
|
11
11
|
rake (13.0.1)
|
12
|
+
rexml (3.2.5)
|
12
13
|
rspec (3.9.0)
|
13
14
|
rspec-core (~> 3.9.0)
|
14
15
|
rspec-expectations (~> 3.9.0)
|
@@ -22,12 +23,15 @@ GEM
|
|
22
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
23
24
|
rspec-support (~> 3.9.0)
|
24
25
|
rspec-support (3.9.3)
|
25
|
-
simplecov (0.
|
26
|
+
simplecov (0.21.2)
|
26
27
|
docile (~> 1.1)
|
27
28
|
simplecov-html (~> 0.11)
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
simplecov_json_formatter (~> 0.1)
|
30
|
+
simplecov-cobertura (2.1.0)
|
31
|
+
rexml
|
32
|
+
simplecov (~> 0.19)
|
33
|
+
simplecov-html (0.12.3)
|
34
|
+
simplecov_json_formatter (0.1.4)
|
31
35
|
|
32
36
|
PLATFORMS
|
33
37
|
ruby
|
data/README.md
CHANGED
@@ -93,7 +93,8 @@ rescue_from ActiveModel::ValidationError, with: lambda { |e| handle_validation_e
|
|
93
93
|
|
94
94
|
def handle_validation_error(error)
|
95
95
|
error_model = error.try(:model) || error.try(:record)
|
96
|
-
|
96
|
+
messages = error_model.errors.messages
|
97
|
+
mapped = JsonapiErrorsHandler::Errors::Invalid.new(errors: messages)
|
97
98
|
render_error(mapped)
|
98
99
|
end
|
99
100
|
```
|
@@ -108,7 +109,7 @@ something unexpected happened.
|
|
108
109
|
|
109
110
|
To do so, just implement the `log_error` method in your controller, that accepts the risen error as an argument.
|
110
111
|
|
111
|
-
```
|
112
|
+
```ruby
|
112
113
|
def log_error(error)
|
113
114
|
#do the fancy logging here
|
114
115
|
end
|
@@ -129,7 +130,7 @@ If you want to have custom error responses being delivered, just create your own
|
|
129
130
|
|
130
131
|
If you want to localize your responses, just create a class:
|
131
132
|
|
132
|
-
```
|
133
|
+
```ruby
|
133
134
|
module Api::Errors
|
134
135
|
class Forbidden < ::JsonapiErrorsHandler::Errors::StandardError
|
135
136
|
def initialize(*)
|