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
committerGitHub <noreply@github.com>2019-12-06 22:40:06 +0100
commit6d7daf6154b1edbfe9a0c0b297baab8cd45658f3 (patch)
tree5469cd0edcccc57d9cdbe6a7aceb8a3217648998 /app/controllers
parent1653ae91ce2fbacd88fc2ad21f15aebb84b71f08 (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 33df75b37..144fdd6ac 100644
--- a/app/controllers/api/base_controller.rb
+++ b/app/controllers/api/base_controller.rb
@@ -20,6 +20,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