Fix uncaught error when invalid date is supplied to API (#19480)

Fix #19213
lolsob-rspec
Eugen Rochko 2022-10-27 14:30:52 +02:00 committed by GitHub
parent 35b5120c5d
commit 4435be82db
1 changed files with 4 additions and 0 deletions

View File

@ -24,6 +24,10 @@ class Api::BaseController < ApplicationController
render json: { error: 'Duplicate record' }, status: 422
end
rescue_from Date::Error do
render json: { error: 'Invalid date supplied' }, status: 422
end
rescue_from ActiveRecord::RecordNotFound do
render json: { error: 'Record not found' }, status: 404
end