ApiVisualEditor: Add logging for RESTBase HTTP errors

Bug: T233127
Change-Id: Ide5138d8f8f462b9c3d7da10f26ff57c9d17f1c9
This commit is contained in:
Bartosz Dziewoński 2019-10-02 00:17:36 +02:00
parent 9dc3ecf4e4
commit 9ce8ae05c7

View file

@ -10,6 +10,7 @@
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\MediaWikiServices;
use MediaWiki\Logger\LoggerFactory;
class ApiVisualEditor extends ApiBase {
@ -25,6 +26,11 @@ class ApiVisualEditor extends ApiBase {
*/
protected $serviceClient;
/**
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* @inheritDoc
*/
@ -32,6 +38,7 @@ class ApiVisualEditor extends ApiBase {
parent::__construct( $main, $name );
$this->veConfig = $config;
$this->serviceClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
$this->logger = LoggerFactory::getInstance( 'VisualEditor' );
}
/**
@ -127,6 +134,17 @@ class ApiVisualEditor extends ApiBase {
);
} else {
// error null, code not 200
$this->logger->warning(
__METHOD__ . ": Received HTTP {code} from RESTBase",
[
'code' => $response['code'],
'trace' => ( new Exception )->getTraceAsString(),
'response' => $response['body'],
'requestPath' => $path,
/** @phan-suppress-next-line PhanTypeInvalidDimOffset */
'requestIfMatch' => $reqheaders['If-Match'] ?? '',
]
);
$this->dieWithError(
[ 'apierror-visualeditor-docserver-http', $response['code'] ],
'apierror-visualeditor-docserver-http'