model_driven_api 3.11.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f561a2d22648c4e007dfc73788277d525bff52b8b441bcafc030d96be12034b
4
- data.tar.gz: c4aab8c26319cfe1988b8fd7ac889c8d5c6b975e4e58eca31a0f566767f017eb
3
+ metadata.gz: cb9afc3599f034ab37d86d55596de1178e05602ad93d7d4dd2a95c6a8bbd0de8
4
+ data.tar.gz: 1c9af1949e7f014dacd324bef341cd3bf51cfc361988d82930bd8979c688ba7a
5
5
  SHA512:
6
- metadata.gz: 2a50be7ab0901fcd345403ce5fa46c6a98446303be27fd380dc4202e37366fe86dc51bbb06dc8a9d9c9350bec20e95938e0ff1ecaa5d25006f2c2dfea53c2491
7
- data.tar.gz: bda7a791bc646f8326ca00efd5ae04b9df7dd02e1f36ffb8e8edbcd40055e24034e47d76594f5f5aae4838ddbe17699f33eb85fbe284d5bf3e538df5f035a1d9
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
- rescue_from ActiveRecord::RecordNotUnique, with: :invalid!
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
@@ -1,3 +1,3 @@
1
1
  module ModelDrivenApi
2
- VERSION = "3.11.4".freeze
2
+ VERSION = "3.11.5".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_driven_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.4
4
+ version: 3.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni