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 +4 -4
- data/lib/onsi/error_responder.rb +22 -10
- data/lib/onsi/version.rb +1 -1
- 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: 0a645bf3aac3bee2b7986c263384f9df5a00f2d3
|
4
|
+
data.tar.gz: b353e411803bf55bc4c7900d55a38c8e24e75b32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70e86b97c6c267302221286efd56404d3d15c92ca0d700e6a84989e368892cf4510a5069f99e3e8171af9bdce3684a42548b88ac02de16b591fa64e3721dcf80
|
7
|
+
data.tar.gz: 0b1a846fe3ba195801669250768a9a5a2b935c1b3ce3ebb585139b424f39308e69a462eefd379a4ba653d6cc0817dc44f724a182283755585d1e04844ead1ec6
|
data/lib/onsi/error_responder.rb
CHANGED
@@ -2,12 +2,11 @@ require 'active_support/concern'
|
|
2
2
|
|
3
3
|
module Onsi
|
4
4
|
##
|
5
|
-
# Handles default errors
|
6
|
-
module
|
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
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.
|
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-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|