From 7385a912e9a5d77cfaf1bb566f733e5ac7d72204 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 10 Feb 2020 13:10:14 +0800 Subject: [PATCH] 1 --- app/controllers/concerns/controller_rescue_handler.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/concerns/controller_rescue_handler.rb b/app/controllers/concerns/controller_rescue_handler.rb index 03d51e1b4..dde6c4a8d 100644 --- a/app/controllers/concerns/controller_rescue_handler.rb +++ b/app/controllers/concerns/controller_rescue_handler.rb @@ -6,12 +6,17 @@ module ControllerRescueHandler Util.logger_error e render json: {status: -1, message: "接口异常"} end + rescue_from Mysql2::Error do |e| + Util.logger_error e + render json: {status: -1, message: "接口数据异常"} + end # rescue_from ActionView::MissingTemplate, with: :object_not_found # rescue_from ActiveRecord::RecordNotFound, with: :object_not_found rescue_from Educoder::TipException, with: :tip_show rescue_from ::ActionView::MissingTemplate, with: :missing_template rescue_from ActiveRecord::RecordNotFound, with: :object_not_found rescue_from ActionController::ParameterMissing, with: :render_parameter_missing + # form validation error rescue_from ActiveModel::ValidationError do |ex| render_error(ex.model.errors.full_messages.join(','))