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: a8db34524ea87abd167f658ec26eac30a013af20
4
- data.tar.gz: 5cc8882ceaa5a3e0aa8e7aaef7217981bb1a2e99
3
+ metadata.gz: d37547ca74905eb364764fee297213694e65c51e
4
+ data.tar.gz: ebe4c6bdddff50fd9d1d50d9ccca0efae2728e59
5
5
  SHA512:
6
- metadata.gz: 191460d4d13635f32e63cebf807c2aeb9069e9e7a81a032f4fec5e2869a5718473298300ebd21cc7a6a55761738de3ca7c3825bfefa16ba7c5767d1b0926926d
7
- data.tar.gz: 27f3676e471036c8982a2451fec68748d33a1d94084755a05c93b0248d3a833bb6890442b9821aeaaab0f9feab8177532136dde5977505cd576f0be430e893a0
6
+ metadata.gz: 72c8788481626a1b7c1403f78cdf638a4bbb51b284662872e1a606ed5d33e5199fe099a0c9628b4ce4ae4892bd4325695d81008217ce328e32e63bd49294d131
7
+ data.tar.gz: 96df41fc08033bc1b78c9386116cbf03b1e5e9b5532f1abb304f88e6bafdb9ddb0e93b3216bd3151dcb02cf158b6c252b2d26944a1e857a5ad012f1ee7011e9e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jsonapi_errorable (0.7.0)
4
+ jsonapi_errorable (0.8.0)
5
5
  jsonapi-serializable (~> 0.1)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jsonapi_errorable (0.7.0)
4
+ jsonapi_errorable (0.8.0)
5
5
  jsonapi-serializable (~> 0.1)
6
6
 
7
7
  GEM
@@ -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
- return {} unless @meta.respond_to?(:call)
38
- @meta.call(error)
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)
@@ -1,3 +1,3 @@
1
1
  module JsonapiErrorable
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
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.8.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-09 00:00:00.000000000 Z
11
+ date: 2017-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializable