异常啊异常
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Aether;
|
||||
|
||||
use Aether\Exception\BusinessException;
|
||||
use Aether\Exception\ValidationFailedException;
|
||||
use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Hyperf\Database\Model\ModelNotFoundException;
|
||||
use Hyperf\ExceptionHandler\ExceptionHandler;
|
||||
@@ -26,6 +27,9 @@ class GlobalExceptionHandler extends ExceptionHandler
|
||||
|
||||
public function handle(Throwable $throwable, ResponseInterface $response): MessageInterface|ResponseInterface
|
||||
{
|
||||
if ($throwable instanceof ValidationFailedException) {
|
||||
return $response->withBody(new SwooleStream($throwable->getMessage()));
|
||||
}
|
||||
// 处理业务异常
|
||||
if ($throwable instanceof BusinessException) {
|
||||
$data = [
|
||||
|
||||
Reference in New Issue
Block a user