jsonapionify 0.10.0 → 0.10.1
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,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTZmYTcyMjIzZGQ1YTcyZGI5M2E4MzM2YmRmNDFlM2FhMjJjMjlmYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZGQxMmU3MDlhMzQyNTRkMzg3ZWNlM2Q3MDFiNjNmNGM4YTRjMzM1Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjI4YTZkZTQxM2VmZTU3NWU2NTNlYmY3OGQ2YjYyOTdlNjU2NmMxZTk3YmI0
|
10
|
+
ODU1YjA5MjE5NjQ0NTc3MzcwOWYyMzJjOWYyNGExYWRkMjkyZGYzNWRlODcx
|
11
|
+
NmYwNGNmYTM2MTU2YzY2M2UyNjQyYmNiYzU3MWRhMzFhMmFhYzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmE5MzlkOWZjOTg5NzlmNGM0ZDFiYzFlZmVjNTQzZGJkYjAwYWMzN2JiMjhi
|
14
|
+
ZTkzNTMxNWE5ZGI2NzcxNWY0ZTc3ZjMxNTdjN2ZmNjQ0NmYwOGJhMjYwZTc2
|
15
|
+
NmQ2ZGYzZjAxMzRiNDlmOGMxMjdmMDE0NzNiYmUzNzAzODNjMTk=
|
@@ -13,7 +13,7 @@ module JSONAPIonify::Api
|
|
13
13
|
rescue Exception => exception
|
14
14
|
response = rescued_response exception, @__context, do_respond
|
15
15
|
ensure
|
16
|
-
self.class.cache_store.delete @cache_options[:key] unless response[0] < 300
|
16
|
+
self.class.cache_store.delete @cache_options[:key] unless !response || response[0] < 300
|
17
17
|
end
|
18
18
|
|
19
19
|
def response_definition
|
@@ -10,13 +10,13 @@ module JSONAPIonify::Api
|
|
10
10
|
context(:errors, readonly: true, persisted: true) do
|
11
11
|
ErrorsObject.new
|
12
12
|
end
|
13
|
-
register_exception Exception, error: :internal_server_error do |exception|
|
13
|
+
register_exception Exception, error: :internal_server_error, callbacks: true do |exception|
|
14
14
|
if JSONAPIonify.verbose_errors
|
15
15
|
detail exception.message
|
16
16
|
meta[:error_class] = exception.class.name
|
17
17
|
end
|
18
18
|
end
|
19
|
-
register_exception Errors::RequestError, error: :internal_server_error do |exception|
|
19
|
+
register_exception Errors::RequestError, error: :internal_server_error, callbacks: true do |exception|
|
20
20
|
if JSONAPIonify.verbose_errors
|
21
21
|
detail exception.message
|
22
22
|
meta[:error_class] = exception.class.name
|
@@ -30,14 +30,21 @@ module JSONAPIonify::Api
|
|
30
30
|
self.error_definitions = self.error_definitions.merge name.to_sym => block
|
31
31
|
end
|
32
32
|
|
33
|
-
def register_exception(*klasses, error:, &block)
|
33
|
+
def register_exception(*klasses, callbacks: false, error:, &block)
|
34
34
|
block ||= proc {}
|
35
35
|
rescue_from(*klasses) do |exception, context|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
evaluate = proc {
|
37
|
+
errors.evaluate(
|
38
|
+
error_block: lookup_error(error),
|
39
|
+
runtime_block: proc { instance_exec exception, context, &block },
|
40
|
+
backtrace: exception.backtrace
|
41
|
+
)
|
42
|
+
}
|
43
|
+
if callbacks
|
44
|
+
run_callbacks :exception, exception, &evaluate
|
45
|
+
else
|
46
|
+
evaluate.call
|
47
|
+
end
|
41
48
|
end
|
42
49
|
end
|
43
50
|
|
data/lib/jsonapionify/version.rb
CHANGED