]> cat aescling's git repositories - mastodon.git/commitdiff
Fix generic HTTP 500 error on duplicate records (#12563)
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 6 Dec 2019 21:40:06 +0000 (22:40 +0100)
committerGitHub <noreply@github.com>
Fri, 6 Dec 2019 21:40:06 +0000 (22:40 +0100)
Fix #12551
Fix #12547

app/controllers/api/base_controller.rb

index 33df75b374b388b8f9bf8cf276cf7574ad5ebd50..144fdd6ac9de99fbb97c4fa23166e9131401f71b 100644 (file)
@@ -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