From 19c62e049c609e0eceefdccf207dba8b7065f030 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Fri, 22 May 2020 15:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=82=E5=B8=B8=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchExceptionHandle.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/extend/catcher/CatchExceptionHandle.php b/extend/catcher/CatchExceptionHandle.php index 1feec71..3f068ee 100644 --- a/extend/catcher/CatchExceptionHandle.php +++ b/extend/catcher/CatchExceptionHandle.php @@ -52,10 +52,27 @@ class CatchExceptionHandle extends Handle public function render($request, Throwable $e): Response { // 其他错误交给系统处理 - if (!$e instanceof CatchException) { - $e = new FailedException($e->getMessage()); + if ($e instanceof \Exception && !$e instanceof CatchException) { + $e = new FailedException($e->getMessage(), 10005, $e); } return parent::render($request, $e); } + + /** + * 重写异常渲染页面 + * + * @time 2020年05月22日 + * @param Throwable $exception + * @return string + */ + protected function renderExceptionContent(Throwable $exception): string + { + ob_start(); + $data = $this->convertExceptionToArray($exception->getPrevious() ? $exception->getPrevious() : $exception); + extract($data); + include $this->app->config->get('app.exception_tmpl') ?: __DIR__ . '/../../tpl/think_exception.tpl'; + + return ob_get_clean(); + } }