This commit is contained in:
Aether
2025-09-18 10:46:54 +08:00
commit 0920cef866
62 changed files with 13547 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Aether\Exception;
use Hyperf\Server\Exception\ServerException;
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,
?array $errorData = null
) {
parent::__construct($message, $code, $previous);
$this->errorData = $errorData;
}
/**
* 获取额外错误数据
*/
public function getErrorData(): ?array
{
return $this->errorData;
}
}