jsonapi_errorable 0.6.2 → 0.7.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 490f57c4519b245889df013a2b57572bb4c6ac19
|
4
|
+
data.tar.gz: 15bcb8cfec13e87914d23be061be69b37ab5b0bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e5c99412abcd2a0a525c33865883b4c8bb95e0882e7bd58cba2666fa56fa585bc33beab9ba0fb5f9aa98a96a992e7ff2aad42acac7e064c0976eab64071fb62
|
7
|
+
data.tar.gz: a9a79c775278c6eeb75259774728f7ee8021fa5a52feedcc4017b1e504580f3d04f032b6c8ef7194e8d9a9ce87a1fd5b6485987d412efdf6e2afb8b6ebb137ee
|
data/.travis.yml
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
|
-
remote:
|
2
|
+
remote: ..
|
3
3
|
specs:
|
4
|
-
jsonapi_errorable (0.
|
5
|
-
|
6
|
-
rails (>= 4.1, < 6)
|
4
|
+
jsonapi_errorable (0.6.2)
|
5
|
+
jsonapi-serializable (~> 0.1)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
@@ -31,11 +30,6 @@ GEM
|
|
31
30
|
erubis (~> 2.7.0)
|
32
31
|
rails-dom-testing (~> 2.0)
|
33
32
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
34
|
-
active_model_serializers (0.10.2)
|
35
|
-
actionpack (>= 4.1, < 6)
|
36
|
-
activemodel (>= 4.1, < 6)
|
37
|
-
jsonapi (~> 0.1.1.beta2)
|
38
|
-
railties (>= 4.1, < 6)
|
39
33
|
activejob (5.0.0.1)
|
40
34
|
activesupport (= 5.0.0.1)
|
41
35
|
globalid (>= 0.3.6)
|
@@ -64,9 +58,9 @@ GEM
|
|
64
58
|
globalid (0.3.7)
|
65
59
|
activesupport (>= 4.1.0)
|
66
60
|
i18n (0.7.0)
|
67
|
-
|
68
|
-
jsonapi (0.1.
|
69
|
-
|
61
|
+
jsonapi-renderer (0.1.2)
|
62
|
+
jsonapi-serializable (0.1.3)
|
63
|
+
jsonapi-renderer (~> 0.1)
|
70
64
|
jsonapi_spec_helpers (0.2.0)
|
71
65
|
loofah (2.0.3)
|
72
66
|
nokogiri (>= 1.5.9)
|
@@ -167,4 +161,4 @@ DEPENDENCIES
|
|
167
161
|
sqlite3
|
168
162
|
|
169
163
|
BUNDLED WITH
|
170
|
-
1.
|
164
|
+
1.15.0
|
@@ -4,6 +4,7 @@ module JsonapiErrorable
|
|
4
4
|
@status = options[:status]
|
5
5
|
@title = options[:title]
|
6
6
|
@message = options[:message]
|
7
|
+
@meta = options[:meta]
|
7
8
|
@log = options[:log]
|
8
9
|
end
|
9
10
|
|
@@ -33,7 +34,8 @@ module JsonapiErrorable
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def meta(error)
|
36
|
-
{}
|
37
|
+
return {} unless @meta.respond_to?(:call)
|
38
|
+
@meta.call(error)
|
37
39
|
end
|
38
40
|
|
39
41
|
def error_payload(error)
|
@@ -16,11 +16,18 @@ module JsonapiErrorable
|
|
16
16
|
messages.map do |message|
|
17
17
|
meta = { attribute: attribute, message: message }.merge(@relationship_message)
|
18
18
|
meta = { relationship: meta } if @relationship_message.present?
|
19
|
+
|
20
|
+
detail = "#{attribute.capitalize} #{message}"
|
21
|
+
|
22
|
+
if attribute.to_s.downcase == 'base'
|
23
|
+
detail = message
|
24
|
+
end
|
25
|
+
|
19
26
|
{
|
20
27
|
code: 'unprocessable_entity',
|
21
28
|
status: '422',
|
22
29
|
title: 'Validation Error',
|
23
|
-
detail:
|
30
|
+
detail: detail,
|
24
31
|
source: { pointer: pointer_for(object, attribute) },
|
25
32
|
meta: meta
|
26
33
|
}
|
data/lib/jsonapi_errorable.rb
CHANGED
@@ -55,6 +55,10 @@ module JsonapiErrorable
|
|
55
55
|
self.class.default_exception_handler
|
56
56
|
end
|
57
57
|
|
58
|
+
def registered_exception?(e)
|
59
|
+
self.class._errorable_registry.key?(e.class)
|
60
|
+
end
|
61
|
+
|
58
62
|
module ClassMethods
|
59
63
|
def register_exception(klass, options = {})
|
60
64
|
exception_klass = options[:handler] || default_exception_handler
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi_errorable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
145
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.6.
|
146
|
+
rubygems_version: 2.6.13
|
147
147
|
signing_key:
|
148
148
|
specification_version: 4
|
149
149
|
summary: jsonapi.org compatible error handling
|