MediaWiki
master
ValidationException.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Wikimedia\ParamValidator
;
4
5
use Throwable;
6
use UnexpectedValueException;
7
use
Wikimedia\Message\DataMessageValue
;
8
16
class
ValidationException
extends
UnexpectedValueException {
17
19
protected
$failureMessage
;
20
22
protected
$paramName
;
23
25
protected
$paramValue
;
26
28
protected
$settings
;
29
38
public
function
__construct
(
39
DataMessageValue
$failureMessage
, $name, $value,
$settings
, ?Throwable $previous =
null
40
) {
41
$this->failureMessage =
$failureMessage
;
42
$this->paramName = $name;
43
$this->paramValue = $value;
44
$this->settings =
$settings
;
45
46
// Parent class needs some static English message.
47
$msg =
"Validation of `$name` failed: "
.
$failureMessage
->
getCode
();
48
$data =
$failureMessage
->
getData
();
49
if
( $data ) {
50
$msg .=
' '
. json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
51
}
52
parent::__construct( $msg, 0, $previous );
53
}
54
63
public
function
getFailureMessage
() {
64
return
$this->failureMessage
;
65
}
66
71
public
function
getParamName
() {
72
return
$this->paramName
;
73
}
74
79
public
function
getParamValue
() {
80
return
$this->paramValue
;
81
}
82
87
public
function
getSettings
() {
88
return
$this->settings
;
89
}
90
91
}
Wikimedia\Message\DataMessageValue
Value object representing a message for i18n with alternative machine-readable data.
Definition
DataMessageValue.php:25
Wikimedia\Message\DataMessageValue\getData
getData()
Get the message's structured data.
Definition
DataMessageValue.php:75
Wikimedia\Message\DataMessageValue\getCode
getCode()
Get the message code.
Definition
DataMessageValue.php:67
Wikimedia\ParamValidator\ValidationException
Error reporting for ParamValidator.
Definition
ValidationException.php:16
Wikimedia\ParamValidator\ValidationException\getParamValue
getParamValue()
Fetch the parameter value that failed validation.
Definition
ValidationException.php:79
Wikimedia\ParamValidator\ValidationException\getSettings
getSettings()
Fetch the settings array that failed validation.
Definition
ValidationException.php:87
Wikimedia\ParamValidator\ValidationException\getFailureMessage
getFailureMessage()
Fetch the validation failure message.
Definition
ValidationException.php:63
Wikimedia\ParamValidator\ValidationException\$paramName
string $paramName
Definition
ValidationException.php:22
Wikimedia\ParamValidator\ValidationException\__construct
__construct(DataMessageValue $failureMessage, $name, $value, $settings, ?Throwable $previous=null)
Definition
ValidationException.php:38
Wikimedia\ParamValidator\ValidationException\$failureMessage
DataMessageValue $failureMessage
Definition
ValidationException.php:19
Wikimedia\ParamValidator\ValidationException\$settings
array $settings
Definition
ValidationException.php:28
Wikimedia\ParamValidator\ValidationException\getParamName
getParamName()
Fetch the parameter name that failed validation.
Definition
ValidationException.php:71
Wikimedia\ParamValidator\ValidationException\$paramValue
mixed $paramValue
Definition
ValidationException.php:25
Wikimedia\ParamValidator
Definition
Callbacks.php:3
includes
libs
ParamValidator
ValidationException.php
Generated on Mon Nov 4 2024 17:24:28 for MediaWiki by
1.10.0