优化
This commit is contained in:
@@ -5,25 +5,30 @@ declare(strict_types=1);
|
||||
namespace Aether\Exception;
|
||||
|
||||
use Hyperf\Server\Exception\ServerException;
|
||||
use Throwable;
|
||||
|
||||
class BusinessException extends ServerException
|
||||
{
|
||||
// 错误码常量(按业务模块划分)
|
||||
public const VALIDATION_ERROR = 400; // 参数验证失败
|
||||
|
||||
public const AUTH_ERROR = 401; // 认证失败
|
||||
|
||||
public const PERMISSION_DENY = 403; // 权限不足
|
||||
|
||||
public const RESOURCE_NOT_FOUND = 404; // 资源不存在
|
||||
|
||||
public const SCENE_NOT_FOUND = 400;
|
||||
|
||||
/**
|
||||
* 额外错误数据(如验证详情)
|
||||
* 额外错误数据(如验证详情).
|
||||
*/
|
||||
protected ?array $errorData = null;
|
||||
|
||||
public function __construct(
|
||||
string $message,
|
||||
int $code = 500,
|
||||
?\Throwable $previous = null,
|
||||
?Throwable $previous = null,
|
||||
?array $errorData = null
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
@@ -31,10 +36,10 @@ class BusinessException extends ServerException
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取额外错误数据
|
||||
* 获取额外错误数据.
|
||||
*/
|
||||
public function getErrorData(): ?array
|
||||
{
|
||||
return $this->errorData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user