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

Fix #19213
local
Eugen Rochko 2 years ago committed by GitHub
parent d2eb726962
commit 3e18e05330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/controllers/api/base_controller.rb

@ -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

Loading…
Cancel
Save