Trying to get away with returning a single code and parameter-list that was supposed to represent both human-readable and machine-readable data was a mistake. This patch converts it to use DataMessageValue, which represents the two separately and also provides guidance for supplying translations of all the error codes. This also eliminates the "describeSettings()" method that was trying to serve multiple use cases (in terms of the Action API, action=paraminfo and action=help). It's replaced by two methods that each serve one of the use cases. Also some of the functionality was moved out of the TypeDef base class into ParamValidator, to better match where the constants themselves live. Also I wound up creating a NumericDef base class so FloatDef can share the same range-checking logic that IntegerDef has. I probably should have done that as a separate patch, but untangling it now would be too much work. Bug: T235801 Change-Id: Iea6d4a1d05bb4b92d60415b0f03ff9d3dc99a80b
20 lines
465 B
PHP
20 lines
465 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Rest;
|
|
|
|
use Wikimedia\Message\MessageValue;
|
|
|
|
class LocalizedHttpException extends HttpException {
|
|
private $messageValue;
|
|
|
|
public function __construct( MessageValue $messageValue, $code = 500, $errorData = null ) {
|
|
parent::__construct(
|
|
'Localized exception with key ' . $messageValue->getKey(), $code, $errorData
|
|
);
|
|
$this->messageValue = $messageValue;
|
|
}
|
|
|
|
public function getMessageValue() {
|
|
return $this->messageValue;
|
|
}
|
|
}
|