Skip to content

Commit

Permalink
ApiVisualEditor: Add logging for RESTBase HTTP errors
Browse files Browse the repository at this point in the history
Bug: T233127
Change-Id: Ide5138d8f8f462b9c3d7da10f26ff57c9d17f1c9
  • Loading branch information
MatmaRex committed Oct 1, 2019
1 parent 9dc3ecf commit 9ce8ae0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions includes/ApiVisualEditor.php
Expand Up @@ -10,6 +10,7 @@

use MediaWiki\Block\DatabaseBlock;
use MediaWiki\MediaWikiServices;
use MediaWiki\Logger\LoggerFactory;

class ApiVisualEditor extends ApiBase {

Expand All @@ -25,13 +26,19 @@ class ApiVisualEditor extends ApiBase {
*/
protected $serviceClient;

/**
* @var \Psr\Log\LoggerInterface
*/
protected $logger;

/**
* @inheritDoc
*/
public function __construct( ApiMain $main, $name, Config $config ) {
parent::__construct( $main, $name );
$this->veConfig = $config;
$this->serviceClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
$this->logger = LoggerFactory::getInstance( 'VisualEditor' );
}

/**
Expand Down Expand Up @@ -127,6 +134,17 @@ protected function requestRestbase( Title $title, $method, $path, $params, $reqh
);
} 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'
Expand Down

0 comments on commit 9ce8ae0

Please sign in to comment.