Files
hyperf_data/extend/Aether/PHP/Hyperf/RpcException/ValidateException.php
2025-09-28 14:51:38 +08:00

39 lines
760 B
PHP

<?php
declare(strict_types=1);
namespace Aether\RpcException;
use Hyperf\Server\Exception\ServerException;
use Throwable;
class ValidateException extends ServerException
{
/**
* @var int 错误码
*/
protected $code;
/**
* @var array 额外数据
*/
protected array $data = [];
public function __construct(string $message = '', int $code = ErrorCode::PARAM_ERROR, array $data = [], ?Throwable $previous = null)
{
if (empty($message)) {
$message = ErrorCode::getMessage($code);
}
$this->code = $code;
$this->data = $data;
parent::__construct($message, $code, $previous);
}
public function getData(): array
{
return $this->data;
}
}