2016-12-17 17:52:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Exceptions that we might conceivably want to report to ordinary users
|
|
|
|
// (i.e. exceptions that don't represent bugs in the extension itself)
|
|
|
|
class AFPUserVisibleException extends AFPException {
|
2018-04-29 17:52:45 +00:00
|
|
|
/** @var string */
|
|
|
|
public $mExceptionID;
|
|
|
|
/** @var int */
|
2016-12-17 17:52:36 +00:00
|
|
|
public $mPosition;
|
2018-04-29 17:52:45 +00:00
|
|
|
/** @var array */
|
2016-12-17 17:52:36 +00:00
|
|
|
public $mParams;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $exception_id
|
|
|
|
* @param int $position
|
|
|
|
* @param array $params
|
|
|
|
*/
|
2018-04-04 21:14:25 +00:00
|
|
|
public function __construct( $exception_id, $position, $params ) {
|
2016-12-17 17:52:36 +00:00
|
|
|
$this->mExceptionID = $exception_id;
|
|
|
|
$this->mPosition = $position;
|
|
|
|
$this->mParams = $params;
|
|
|
|
|
|
|
|
// Exception message text for logs should be in English.
|
|
|
|
$msg = $this->getMessageObj()->inLanguage( 'en' )->useDatabase( false )->text();
|
|
|
|
parent::__construct( $msg );
|
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2018-06-08 06:11:09 +00:00
|
|
|
* @return Message
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
2016-12-17 17:52:36 +00:00
|
|
|
public function getMessageObj() {
|
|
|
|
// Give grep a chance to find the usages:
|
|
|
|
// abusefilter-exception-unexpectedatend, abusefilter-exception-expectednotfound
|
|
|
|
// abusefilter-exception-unrecognisedkeyword, abusefilter-exception-unexpectedtoken
|
|
|
|
// abusefilter-exception-unclosedstring, abusefilter-exception-invalidoperator
|
|
|
|
// abusefilter-exception-unrecognisedtoken, abusefilter-exception-noparams
|
|
|
|
// abusefilter-exception-dividebyzero, abusefilter-exception-unrecognisedvar
|
|
|
|
// abusefilter-exception-notenoughargs, abusefilter-exception-regexfailure
|
|
|
|
// abusefilter-exception-overridebuiltin, abusefilter-exception-outofbounds
|
2018-04-10 17:26:02 +00:00
|
|
|
// abusefilter-exception-notlist, abusefilter-exception-unclosedcomment
|
2016-03-07 17:09:13 +00:00
|
|
|
// abusefilter-exception-invalidiprange
|
2016-12-17 17:52:36 +00:00
|
|
|
return wfMessage(
|
|
|
|
'abusefilter-exception-' . $this->mExceptionID,
|
2018-06-08 03:16:42 +00:00
|
|
|
$this->mPosition, ...$this->mParams
|
2016-12-17 17:52:36 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|