MediaWiki  master
ValidationException.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Exception;
6 use Throwable;
9 
17 
19  protected $failureMessage;
20 
22  protected $paramName;
23 
25  protected $paramValue;
26 
28  protected $settings;
29 
37  public function __construct(
38  DataMessageValue $failureMessage, $name, $value, $settings, $previous = null
39  ) {
40  $this->failureMessage = $failureMessage;
41  $this->paramName = $name;
42  $this->paramValue = $value;
43  $this->settings = $settings;
44 
45  // Parent class needs some static English message.
46  $msg = "Validation of `$name` failed: " . $failureMessage->getCode();
47  $data = $failureMessage->getData();
48  if ( $data ) {
49  $msg .= ' ' . json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
50  }
51  parent::__construct( $msg, 0, $previous );
52  }
53 
62  public function getFailureMessage() {
63  return $this->failureMessage;
64  }
65 
70  public function getParamName() {
71  return $this->paramName;
72  }
73 
78  public function getParamValue() {
79  return $this->paramValue;
80  }
81 
86  public function getSettings() {
87  return $this->settings;
88  }
89 
90 }
Value object representing a message for i18n with alternative machine-readable data.
__construct(DataMessageValue $failureMessage, $name, $value, $settings, $previous=null)
getSettings()
Fetch the settings array that failed validation.
getParamValue()
Fetch the parameter value that failed validation.
getParamName()
Fetch the parameter name that failed validation.
Error reporting for ParamValidator.
getData()
Get the message&#39;s structured data.
getFailureMessage()
Fetch the validation failure message.