* @copyright walkor * @link http://www.workerman.net/ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ namespace support; use app\exception\SysException; use Throwable; use Webman\Exception\ExceptionHandler; use Webman\Exception\ExceptionHandlerInterface; use Webman\Http\Request; use Webman\Http\Response; use Webman\Exception\BusinessException; /** * Class Handler * @package support\exception */ class MyExceptionHandle extends ExceptionHandler implements ExceptionHandlerInterface { public $dontReport = [ BusinessException::class, ]; public function report(Throwable $exception) { Log::error("捕获到全局异常,异常信息: ".$exception->getMessage()); Log::error($exception->getTraceAsString()); parent::report($exception); } public function render(Request $request, Throwable $exception): Response { return json( [ 'code' => -1, 'message' => $exception->getMessage(), 'time' => time(), 'data' => [], ]); } }