求助,Laravel 重新接管 dingoApi 错误

因为在项目上线后要屏蔽sql方面的报错,所有按网上教的我让laravel重新接管的错误处理
我在app/Providers/AppServiceProviderboot 方法里加上了

// 将所有的 Exception 全部交给 App\Exceptions\Handler 来处理\
app('api.exception')->register(function (\Exception $exception) {\
    $request = Request::capture();\
    return app('App\Exceptions\Handler')->render($request, $exception);\
});

然后修改 app/Exceptions/Handle 中的 render 方法

public function render($request, Exception $exception)\
{
    $class = get_class($exception);
    if ((!env('API_DEBUG'))
        && in_array($class, self::SHIELD_ERR)) {
        return [
            'status_code' => 500,
            'message' => '服务异常',
            'data' => []
        ];
    }
}
// 屏蔽报错列表\
const SHIELD_ERR = [
    'Illuminate\Database\QueryException'
];

上线后再日志里看到这个报错

Call to a member function send() on null {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function send() on null at /www/wwwroot/MeijietuWebApi/public/index.php:58)
[stacktrace]
#0 {main}
"}              
Uncaught Error: Call to a member function send() on null
in /www/wwwroot/MeijietuWebApi/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:112
Stack trace:
#0 /www/wwwroot/MeijietuWebApi/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(89): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 {main}
  thrown {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 1): Uncaught Error: Call to a member function send() on null in /www/wwwroot/MeijietuWebApi/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:112
Stack trace:
#0 /www/wwwroot/MeijietuWebApi/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(89): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->renderHttpResponse(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#1 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException(Object(Symfony\\Component\\Debug\\Exception\\FatalThrowableError))
#2 {main}
  thrown at /www/wwwroot/MeijietuWebApi/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:112)
[stacktrace]
#0 {main}
"}   

目前没发现会有什么影响,但还是想修好,就是看不懂

本作品采用《CC 协议》,转载必须注明作者和本文链接
Maybe we are frend.
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!