From 18b7c3c2db70bdcf858621a6cf07d534c25fa268 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 21 Feb 2020 15:56:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../concerns/controller_rescue_handler.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/controllers/concerns/controller_rescue_handler.rb b/app/controllers/concerns/controller_rescue_handler.rb index 6ff15cfbc..921ed718d 100644 --- a/app/controllers/concerns/controller_rescue_handler.rb +++ b/app/controllers/concerns/controller_rescue_handler.rb @@ -10,14 +10,6 @@ module ControllerRescueHandler Util.logger_error e render json: {status: -1, message: "接口数据异常"} end - rescue_from NoMethodError do |e| - Util.logger_error e - render json: {status: -1, message: "接口方法异常"} - end - - rescue_from ActionController::UnknownFormat do |e| - render json: {status: -1, message: "接口调用非JSON格式"} - end # rescue_from ActionView::MissingTemplate, with: :object_not_found # rescue_from ActiveRecord::RecordNotFound, with: :object_not_found rescue_from Educoder::TipException, with: :tip_show @@ -32,6 +24,11 @@ module ControllerRescueHandler rescue_from ActiveRecord::RecordInvalid do |ex| render_error(ex.record.errors.full_messages.join(',')) end + + rescue_from ActionController::UnknownFormat do |e| + render json: {status: -1, message: "接口调用非JSON格式"} + end + # rescue_from RuntimeError do |ex| # Util.logger_error "#######ex:#{ex}" # render_error(ex.message)