about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-12-06 22:40:06 +0100
committermultiple creatures <dev@multiple-creature.party>2020-02-20 23:17:16 -0600
commitf521c4fb033c3c5b5f745f477ac29fd8993dc510 (patch)
treed43a005e7bd8cbd8584e0d7088c036737fe3f461 /app/controllers
parent90623848734cb2c51b94ca7a82c3477414a86a92 (diff)
Fix generic HTTP 500 error on duplicate records (#12563)
Fix #12551
Fix #12547
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/base_controller.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb
index eca558f42..f5892f96c 100644
--- a/app/controllers/api/base_controller.rb
+++ b/app/controllers/api/base_controller.rb
@@ -17,6 +17,10 @@ class Api::BaseController < ApplicationController
     render json: { error: e.to_s }, status: 422
   end
 
+  rescue_from ActiveRecord::RecordNotUnique do
+    render json: { error: 'Duplicate record' }, status: 422
+  end
+
   rescue_from ActiveRecord::RecordNotFound do
     render json: { error: 'Record not found' }, status: 404
   end