27 lines
602 B
PHP
27 lines
602 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use app\common\service\JsonService;
|
|
use Next\VarDumper\Dumper;
|
|
use Next\VarDumper\DumperHandler;
|
|
use support\exception\Handler;
|
|
use Throwable;
|
|
use Webman\Http\Request;
|
|
use Webman\Http\Response;
|
|
|
|
class ExceptionHandler extends Handler
|
|
{
|
|
|
|
use DumperHandler;
|
|
|
|
public function render(Request $request, Throwable $exception): Response
|
|
{
|
|
if ($exception instanceof Dumper) {
|
|
return \response(self::convertToHtml($exception));
|
|
}
|
|
// 非json请求则返回一个页面
|
|
return new Response(200, [], $exception->getMessage());
|
|
}
|
|
}
|