From 7fbce21622b8abf1312e06f587c76b1a18392135 Mon Sep 17 00:00:00 2001 From: ctexthuang Date: Tue, 12 Nov 2024 11:45:49 +0800 Subject: [PATCH] feat : exception --- app/Exception/ErrException.php | 7 ++++++- app/Exception/Handler/ErrExceptionHandler.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Exception/ErrException.php b/app/Exception/ErrException.php index 29c039b..74d779a 100644 --- a/app/Exception/ErrException.php +++ b/app/Exception/ErrException.php @@ -2,9 +2,14 @@ namespace App\Exception; +use App\Constants\ReturnCode; use Hyperf\Server\Exception\ServerException; class ErrException extends ServerException { - + /** + * 重写抛出错误的状态码 + * @var int + */ + protected $code = ReturnCode::ERROR; } \ No newline at end of file diff --git a/app/Exception/Handler/ErrExceptionHandler.php b/app/Exception/Handler/ErrExceptionHandler.php index 862e13a..ceadcbf 100644 --- a/app/Exception/Handler/ErrExceptionHandler.php +++ b/app/Exception/Handler/ErrExceptionHandler.php @@ -2,6 +2,7 @@ namespace App\Exception\Handler; +use App\Constants\ReturnCode; use App\Exception\ErrException; use App\Lib\AdminReturn; use App\Lib\ApiReturn;