Browse Source

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

Fix #12551
Fix #12547
master
Eugen Rochko 4 years ago
committed by GitHub
parent
commit
6d7daf6154
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      app/controllers/api/base_controller.rb

+ 4
- 0
app/controllers/api/base_controller.rb 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

Loading…
Cancel
Save