model_driven_api 3.11.0 → 3.11.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 +4 -4
- data/lib/concerns/api_exception_management.rb +12 -2
- data/lib/model_driven_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b61b86707e2570cba451926c97e8f3859aab908d3cafeeeb4a3ef1a1688319db
|
|
4
|
+
data.tar.gz: 05d89a0b5675947a69579aeab316fc320de7e061c648d13882148c1c471c462f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 266a7903c7736fa65577d7e7f33466a965882af174619b957755eca5ca8901c920429a3c39daf48f1689450d40177a71a4db9c413eb4442210abae2c4ec3f6ec
|
|
7
|
+
data.tar.gz: 37139ea1c430213aa4e8bdd43b9d770f7e08bd7d1df4bd898dd561a3112f550d9ded0b411f38ab4bd982af5716a0b0963042aca2c7a782d25b59fa7f459dc850
|
|
@@ -3,6 +3,12 @@ module ApiExceptionManagement
|
|
|
3
3
|
|
|
4
4
|
included do
|
|
5
5
|
if Rails.env.production?
|
|
6
|
+
# ORDER MATTERS: Rails tries rescue_from handlers from the LAST declared to the
|
|
7
|
+
# first, so the StandardError catch-all must be declared FIRST. Declared last (as it
|
|
8
|
+
# was until 3.11.0) it shadowed every specific handler below: in production every
|
|
9
|
+
# AccessDenied (wrong login credentials), RecordNotFound, RecordInvalid, CanCan
|
|
10
|
+
# denial... answered 500. Covered by spec/lib/concerns/api_exception_management_spec.rb.
|
|
11
|
+
rescue_from StandardError, with: :fivehundred!
|
|
6
12
|
rescue_from NoMethodError, with: :not_found!
|
|
7
13
|
rescue_from CanCan::AccessDenied, with: :unauthorized!
|
|
8
14
|
rescue_from AuthenticateUser::AccessDenied, with: :unauthenticated!
|
|
@@ -17,8 +23,12 @@ module ApiExceptionManagement
|
|
|
17
23
|
rescue_from ActiveRecord::RecordNotUnique, with: :invalid!
|
|
18
24
|
# Rescue Stale Object in Optimistick locking with stale!
|
|
19
25
|
rescue_from ActiveRecord::StaleObjectError, with: :stale!
|
|
20
|
-
rescue_from EndpointValidationError, with: :
|
|
21
|
-
|
|
26
|
+
rescue_from EndpointValidationError, with: :endpoint_invalid!
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# api_error takes keywords only, so it can't be a rescue_from handler itself.
|
|
30
|
+
def endpoint_invalid! exception = EndpointValidationError.new
|
|
31
|
+
return api_error status: 501, errors: exception.message
|
|
22
32
|
end
|
|
23
33
|
|
|
24
34
|
def stale! exception = StandardError.new
|