参考这个方式处理 https://robots.thoughtbot.com/catching-json-parse-errors-with-custom-middleware ,提示“No such middleware to insert before: ActionDispatch::ParamsParser”。
运行 rake middleware 结果如下:(确实没有 ActionDispatch::ParamsParser)
use Rack::Sendfile
use ActionDispatch::Static
use ActionDispatch::Executor
use ActiveSupport::Cache::Strategy::LocalCache::Middleware
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Sprockets::Rails::QuietAssets
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use WebConsole::Middleware
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
run RailsChecheDataaudit::Application.routes
改为
config.middleware.insert_before ActionDispatch::Static, 'CatchJsonParseErrors'
仍然无法捕获异常。应该如何处理?