Browse Source

修正

master
xyiege 1 year ago
parent
commit
822c67482c
  1. 25
      app/ExceptionHandle.php

25
app/ExceptionHandle.php

@ -34,20 +34,10 @@ class ExceptionHandle extends Handle
* @param Throwable $exception * @param Throwable $exception
* @return void * @return void
*/ */
public function report(Throwable $exception): Response public function report(Throwable $exception): void
{ {
// 手动触发的异常 BaseException // 使用内置的方式记录异常日志
if ($e instanceof BaseException) { parent::report($exception);
$this->status = $e->status;
$this->message = $e->message;
$this->data = $e->data;
$extend = property_exists($e, 'extend') ? $e->extend : [];
return $this->output($extend);
}else{
// 使用内置的方式记录异常日志
parent::report($exception);
}
} }
/** /**
@ -61,7 +51,14 @@ class ExceptionHandle extends Handle
public function render($request, Throwable $e): Response public function render($request, Throwable $e): Response
{ {
// 添加自定义异常处理机制 // 添加自定义异常处理机制
// 手动触发的异常 BaseException
if ($e instanceof BaseException) {
$this->status = $e->status;
$this->message = $e->message;
$this->data = $e->data;
$extend = property_exists($e, 'extend') ? $e->extend : [];
return $this->output($extend);
}
// 其他错误交给系统处理 // 其他错误交给系统处理
return parent::render($request, $e); return parent::render($request, $e);
} }

Loading…
Cancel
Save