From e2173ef50fba6103a296a5b6fa9e462f77084294 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 --- app/controllers/concerns/controller_rescue_handler.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/concerns/controller_rescue_handler.rb b/app/controllers/concerns/controller_rescue_handler.rb index 60ac09d64..e680f32c1 100644 --- a/app/controllers/concerns/controller_rescue_handler.rb +++ b/app/controllers/concerns/controller_rescue_handler.rb @@ -10,6 +10,7 @@ module ControllerRescueHandler 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 @@ -24,6 +25,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)