jsonapi_errorable 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d37547ca74905eb364764fee297213694e65c51e
|
4
|
+
data.tar.gz: ebe4c6bdddff50fd9d1d50d9ccca0efae2728e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c8788481626a1b7c1403f78cdf638a4bbb51b284662872e1a606ed5d33e5199fe099a0c9628b4ce4ae4892bd4325695d81008217ce328e32e63bd49294d131
|
7
|
+
data.tar.gz: 96df41fc08033bc1b78c9386116cbf03b1e5e9b5532f1abb304f88e6bafdb9ddb0e93b3216bd3151dcb02cf158b6c252b2d26944a1e857a5ad012f1ee7011e9e
|
data/lib/jsonapi_errorable.rb
CHANGED
@@ -41,10 +41,11 @@ module JsonapiErrorable
|
|
41
41
|
@logger = logger
|
42
42
|
end
|
43
43
|
|
44
|
-
def handle_exception(e)
|
44
|
+
def handle_exception(e, show_raw_error: false)
|
45
45
|
raise e if JsonapiErrorable.disabled?
|
46
46
|
|
47
47
|
exception_klass = self.class._errorable_registry[e.class] || default_exception_handler.new
|
48
|
+
exception_klass.show_raw_error = show_raw_error
|
48
49
|
exception_klass.log(e)
|
49
50
|
json = exception_klass.error_payload(e)
|
50
51
|
status = exception_klass.status_code(e)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module JsonapiErrorable
|
2
2
|
class ExceptionHandler
|
3
|
+
attr_accessor :show_raw_error
|
4
|
+
|
3
5
|
def initialize(options = {})
|
4
6
|
@status = options[:status]
|
5
7
|
@title = options[:title]
|
@@ -34,8 +36,18 @@ module JsonapiErrorable
|
|
34
36
|
end
|
35
37
|
|
36
38
|
def meta(error)
|
37
|
-
|
38
|
-
|
39
|
+
{}.tap do |meta_payload|
|
40
|
+
if @meta.respond_to?(:call)
|
41
|
+
meta_payload.merge!(@meta.call(error))
|
42
|
+
end
|
43
|
+
|
44
|
+
if show_raw_error
|
45
|
+
meta_payload[:__raw_error__] = {
|
46
|
+
message: error.message,
|
47
|
+
backtrace: error.backtrace.join("\n")
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
39
51
|
end
|
40
52
|
|
41
53
|
def error_payload(error)
|
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.9.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-
|
11
|
+
date: 2017-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsonapi-serializable
|