onsi 0.6.0 → 0.7.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: 94fc907d0596232a5b1887ca45501685688f2589
4
- data.tar.gz: f0dde3db9f4427caf83c0dbec973adc8c79d2c6c
3
+ metadata.gz: 0a645bf3aac3bee2b7986c263384f9df5a00f2d3
4
+ data.tar.gz: b353e411803bf55bc4c7900d55a38c8e24e75b32
5
5
  SHA512:
6
- metadata.gz: a75e6341474d6b4f0ce9ab96478455f91268fba1d86a14b4f52e0ef32382fe6d52910662cad050a33f58cb8c40134cfd82a5a00985666e86a13bef8bb71a4882
7
- data.tar.gz: c5561a0006ebe969907206a29445bd9ad320e061110cc7a15714d8adcb9a362f9846895e990d9b998edf43f9aa0c4bbaf7566745ce342c1b954f321af75160f6
6
+ metadata.gz: 70e86b97c6c267302221286efd56404d3d15c92ca0d700e6a84989e368892cf4510a5069f99e3e8171af9bdce3684a42548b88ac02de16b591fa64e3721dcf80
7
+ data.tar.gz: 0b1a846fe3ba195801669250768a9a5a2b935c1b3ce3ebb585139b424f39308e69a462eefd379a4ba653d6cc0817dc44f724a182283755585d1e04844ead1ec6
@@ -2,12 +2,11 @@ require 'active_support/concern'
2
2
 
3
3
  module Onsi
4
4
  ##
5
- # Handles default errors and builds JSON-API responses.
6
- module ErrorResponder
5
+ # Handles default errors without StandardError
6
+ module ErrorResponderBase
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  included do
10
- rescue_from StandardError, with: :render_error_500
11
10
  rescue_from ActiveRecord::RecordNotFound, with: :render_error_404
12
11
  rescue_from ActiveRecord::RecordInvalid, with: :render_error_422
13
12
  rescue_from ActionController::ParameterMissing, with: :respond_param_error_400
@@ -20,13 +19,6 @@ module Onsi
20
19
  render(response.renderable)
21
20
  end
22
21
 
23
- def render_error_500(error)
24
- notify_unhandled_exception(error)
25
- response = ErrorResponse.new(500)
26
- response.add(500, 'internal_server_error', meta: error_metadata(error))
27
- render_error(response)
28
- end
29
-
30
22
  def render_error_404(_error)
31
23
  response = ErrorResponse.new(404)
32
24
  response.add(404, 'not_found')
@@ -140,3 +132,23 @@ module Onsi
140
132
  end
141
133
  end
142
134
  end
135
+
136
+ module Onsi
137
+ ##
138
+ # Handles default errors and builds JSON-API responses.
139
+ module ErrorResponder
140
+ extend ActiveSupport::Concern
141
+
142
+ included do
143
+ rescue_from StandardError, with: :render_error_500
144
+ include(Onsi::ErrorResponderBase)
145
+ end
146
+
147
+ def render_error_500(error)
148
+ notify_unhandled_exception(error)
149
+ response = ErrorResponse.new(500)
150
+ response.add(500, 'internal_server_error', meta: error_metadata(error))
151
+ render_error(response)
152
+ end
153
+ end
154
+ end
data/lib/onsi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Onsi
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onsi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skylar Schipper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-08 00:00:00.000000000 Z
11
+ date: 2018-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails