json_api_toolbox 0.12.1 → 0.13.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 +5 -0
- data/lib/json_api_toolbox/version.rb +1 -1
- data/lib/renderizable_exceptions.rb +29 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73b91ef1e5dadc1e481b783fe817242c60c340d9
|
4
|
+
data.tar.gz: 6ab51aa214846f0d6100ba92529bce53abfcfa3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50155433bc66dd3e51a60c59e1210a7e84a83514c9cf2730c537ce00c394b4c08ba9846ec9ff194e8b9df1d224a8cac0c5c68a4ece3cae1507a55e4ddf98b838
|
7
|
+
data.tar.gz: 0a9510a7c553e0ac321e160b1510e93c7d41e0ade07e710fe64f305d576496fb1788a097a31dfb152668c2a729620683112648552e9d1e8f65caec3cdda0ad21
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.12.2] - 2018-05-02
|
10
|
+
### Changed
|
11
|
+
- Added error details on exception renderizable
|
12
|
+
- Added exception log
|
13
|
+
|
9
14
|
## [0.12.1] - 2018-04-04
|
10
15
|
### Changed
|
11
16
|
- Bug fix proxy at Service class
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support'
|
4
|
-
require 'pry'
|
5
4
|
|
6
5
|
module JsonApiToolbox
|
7
6
|
module RenderizableExceptions
|
@@ -12,16 +11,38 @@ module JsonApiToolbox
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def render_any_exception(exception)
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
puts_build_log_error(exception)
|
15
|
+
|
16
|
+
render build_jsonapi(exception)
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_jsonapi(exception)
|
20
|
+
{ jsonapi_errors:
|
21
|
+
{ title: exception.class.to_s,
|
18
22
|
detail: exception.message,
|
19
|
-
|
20
|
-
|
23
|
+
status: 500,
|
24
|
+
code: code(exception),
|
25
|
+
source: {} },
|
21
26
|
jsonapi_class: {
|
22
27
|
class: { Hash: JsonApiToolbox::Serializables::SerializableException }
|
23
|
-
}
|
24
|
-
|
28
|
+
} }
|
29
|
+
end
|
30
|
+
|
31
|
+
def puts_build_log_error(error)
|
32
|
+
puts messages: error.try(:message), trace: error.try(:backtrace)
|
33
|
+
end
|
34
|
+
|
35
|
+
def code(exception)
|
36
|
+
model_errors_code(exception) ||
|
37
|
+
exception.try(:code) ||
|
38
|
+
'default_error'
|
39
|
+
end
|
40
|
+
|
41
|
+
def model_errors_code(error)
|
42
|
+
detail_error = error.try(:detail)
|
43
|
+
detail_error.try(:map, &:flatten).try(:map) do |item|
|
44
|
+
[item[0], item[1]['error']].join('_error_')
|
45
|
+
end
|
25
46
|
end
|
26
47
|
end
|
27
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adriano Bacha
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|