Fix generic HTTP 500 error on duplicate records (#12563)

Fix #12551
Fix #12547
lolsob-rspec
Eugen Rochko 2019-12-06 22:40:06 +01:00 committed by GitHub
parent a2f67154a4
commit 2eda06b768
1 changed files with 4 additions and 0 deletions

View 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