6
0
Fork 0

优化异常处理

release
李静 2021-12-21 10:20:25 +08:00
parent 0a5eb23a4c
commit 7ad4eafe84
1 changed files with 16 additions and 7 deletions

View File

@ -107,15 +107,24 @@ class Handler extends ExceptionHandler
*/
protected function convertExceptionToArray(Throwable $e)
{
return array_merge(
parent::convertExceptionToArray($e),
$this->isBizException($e) ? [
$data = [
'errcode' => 500,
'message' => config('app.debug') ? $e->getMessage() : '服务器繁忙,请稍后再试',
];
if ($this->isBizException($e)) {
$data = [
'errcode' => $e->getCode(),
'message' => $e->getMessage(),
] : [
'errcode' => $this->isHttpException($e) ? $e->getStatusCode() : 500,
]
);
];
} elseif ($this->isHttpException($e)) {
$data = [
'errcode' => $e->getStatusCode(),
'message' => $e->getMessage(),
];
}
return array_merge(parent::convertExceptionToArray($e), $data);
}
/**