model_driven_api 3.11.3 → 3.11.5
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 +10 -1
- data/lib/model_driven_api/version.rb +1 -1
- data/lib/model_driven_api.rb +4 -0
- 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: cb9afc3599f034ab37d86d55596de1178e05602ad93d7d4dd2a95c6a8bbd0de8
|
|
4
|
+
data.tar.gz: 1c9af1949e7f014dacd324bef341cd3bf51cfc361988d82930bd8979c688ba7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 52ee2968b5191da54df00040993a8882b45d3ac541f68f336aaff76253a3f71f81fcac1157797da4e7d70ea5e43a11163479e13db04fc46d3ef04baf64f99ffd
|
|
7
|
+
data.tar.gz: fe03e92b64d3b8d260f94b4e3bb03ec4d9b8576d464d5ba6adafb96538af53f7aa671b32511cba6bbd255accd4e8bcb8dec14d7e80090c4c4749fc6a435f6437
|
|
@@ -19,7 +19,9 @@ module ApiExceptionManagement
|
|
|
19
19
|
# #destroy! — reuse invalid! since both exceptions expose the same .record interface.
|
|
20
20
|
rescue_from ActiveRecord::RecordNotDestroyed, with: :invalid!
|
|
21
21
|
rescue_from ActiveRecord::RecordNotFound, with: :not_found!
|
|
22
|
-
|
|
22
|
+
# Not invalid!: RecordNotUnique carries no .record, so invalid! itself raised and
|
|
23
|
+
# every unique-index violation answered 500.
|
|
24
|
+
rescue_from ActiveRecord::RecordNotUnique, with: :not_unique!
|
|
23
25
|
# Rescue Stale Object in Optimistick locking with stale!
|
|
24
26
|
rescue_from ActiveRecord::StaleObjectError, with: :stale!
|
|
25
27
|
rescue_from EndpointValidationError, with: :endpoint_invalid!
|
|
@@ -51,6 +53,13 @@ module ApiExceptionManagement
|
|
|
51
53
|
return api_error status: 422, errors: exception.record.errors
|
|
52
54
|
end
|
|
53
55
|
|
|
56
|
+
# The database message names tables, columns and index definitions: log it, don't
|
|
57
|
+
# send it back.
|
|
58
|
+
def not_unique! exception = ActiveRecord::RecordNotUnique.new
|
|
59
|
+
Rails.logger.warn("RecordNotUnique: #{exception.message}")
|
|
60
|
+
return api_error status: 422, errors: "A record with the same unique values already exists"
|
|
61
|
+
end
|
|
62
|
+
|
|
54
63
|
def fivehundred! exception = StandardError.new
|
|
55
64
|
return api_error status: 500, errors: exception.message
|
|
56
65
|
end
|
data/lib/model_driven_api.rb
CHANGED
|
@@ -7,6 +7,10 @@ require 'jwt'
|
|
|
7
7
|
require 'json_web_token'
|
|
8
8
|
require "kaminari"
|
|
9
9
|
require "pagy"
|
|
10
|
+
# jsonapi-serializer backs every /api/v3 response (Api::V3::SerializerFactory). A host gets it
|
|
11
|
+
# only transitively, so Bundler.require never loads it: without this require every v3 request
|
|
12
|
+
# answered 500 "uninitialized constant Api::V3::SerializerFactory::JSONAPI".
|
|
13
|
+
require "jsonapi/serializer"
|
|
10
14
|
# require "multi_json"
|
|
11
15
|
require "simple_command"
|
|
12
16
|
|