* Add ResponseFactory::createLocalizedHttpError(), which generates a JSON response body from a MessageValue * ResponseFactory::__construct() accepts an array of TextFormatter objects. For ease of testing, the array may be empty. The integrated ResponseFactory has a TextFormatter for English, and one for $wgContLang if that is different. * Use createLocalizedHttpError() to show helpful error messages for errors generated by Router. Change-Id: I897a0aee42227916c568333ab384966f1b87f599
18 lines
429 B
PHP
18 lines
429 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Rest;
|
|
|
|
use Wikimedia\Message\MessageValue;
|
|
|
|
class LocalizedHttpException extends HttpException {
|
|
private $messageValue;
|
|
|
|
public function __construct( MessageValue $messageValue, $code = 500 ) {
|
|
parent::__construct( 'Localized exception with key ' . $messageValue->getKey(), $code );
|
|
$this->messageValue = $messageValue;
|
|
}
|
|
|
|
public function getMessageValue() {
|
|
return $this->messageValue;
|
|
}
|
|
}
|