Skip to content

Commit

Permalink
fix(exception): fix not load exception handle 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
TIGERB committed May 21, 2017
1 parent ae10aa9 commit 64665dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
12 changes: 10 additions & 2 deletions framework/handles/ExceptionHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
13 changes: 5 additions & 8 deletions framework/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -117,7 +114,7 @@
$app->response(function () {
return new Response();
});
} catch (CoreHttpException $e) {
} catch (CoreHttException $e) {
/**
* 捕获异常
*
Expand Down

0 comments on commit 64665dd

Please sign in to comment.