MediaWiki REL1_39
ValidationException.php
Go to the documentation of this file.
1<?php
2
4
5use Throwable;
6use UnexpectedValueException;
8
16class 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() {
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}
Value object representing a message for i18n with alternative machine-readable data.
getData()
Get the message's structured data.
getParamValue()
Fetch the parameter value that failed validation.
getSettings()
Fetch the settings array that failed validation.
getFailureMessage()
Fetch the validation failure message.
__construct(DataMessageValue $failureMessage, $name, $value, $settings, Throwable $previous=null)
getParamName()
Fetch the parameter name that failed validation.