diff --git a/framework/handles/ExceptionHandle.php b/framework/handles/ExceptionHandle.php index 3dc5bac..eb17385 100644 --- a/framework/handles/ExceptionHandle.php +++ b/framework/handles/ExceptionHandle.php @@ -49,7 +49,15 @@ public function register(App $app) */ public function exceptionHandler($exception) { - throw $exception; - } + $exceptionInfo = [ + 'code' => $exception->getCode(), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'trace' => $exception->getTrace(), + 'previous' => $exception->getPrevious() + ]; + CoreHttpException::reponseErr($exceptionInfo); + } } diff --git a/framework/run.php b/framework/run.php index 910c616..985160c 100644 --- a/framework/run.php +++ b/framework/run.php @@ -65,13 +65,10 @@ return new ErrorHandle(); }); - // $app->load(function () { - // // 加载异常处理机制 由于本文件全局catch了异常 所以不存在未捕获异常 - // // 可省略注册未捕获异常Handle - // // Loading exception handle. - // // I'm not used it, because this file catch all exception - // return new ExceptionHandle(); - // }); + $app->load(function () { + // 加载异常处理机制 Loading exception handle. + return new ExceptionHandle(); + }); $app->load(function () { // 加载nosql机制 Loading nosql handle @@ -117,7 +114,7 @@ $app->response(function () { return new Response(); }); -} catch (CoreHttpException $e) { +} catch (CoreHttException $e) { /** * 捕获异常 *