36 lines
903 B
PHP
36 lines
903 B
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace Aether\Exception;
|
||
|
||
use Hyperf\Validation\ValidationException;
|
||
use Hyperf\Validation\Validator;
|
||
use Psr\Http\Message\ResponseInterface;
|
||
|
||
class ValidationFailedException extends ValidationException
|
||
{
|
||
/**
|
||
* 验证场景.
|
||
*/
|
||
protected string $scene;
|
||
|
||
public function __construct(
|
||
Validator $validator,
|
||
string $scene,
|
||
string $message = '参数验证失败',
|
||
?ResponseInterface $response = null // 新增response参数,符合父类要求
|
||
) {
|
||
// 父类构造函数仅接受 $validator 和 $response
|
||
parent::__construct($validator, $response);
|
||
// 单独设置消息(父类的 $message 为 protected 属性,可直接赋值)
|
||
$this->message = $message;
|
||
$this->scene = $scene;
|
||
}
|
||
|
||
public function getScene(): string
|
||
{
|
||
return $this->scene;
|
||
}
|
||
}
|