use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use Wikimedia\Timestamp\TimestampException;
-use Wikimedia\Rdbms\DBQueryError;
-use Wikimedia\Rdbms\DBError;
/**
* This is the main API class, used for both external and internal processing.
$this->executeAction();
$runTime = microtime( true ) - $t;
$this->logRequest( $runTime );
- if ( $this->mModule->isWriteMode() && $this->getRequest()->wasPosted() ) {
- MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
- 'api.' . $this->mModule->getModuleName() . '.executeTiming', 1000 * $runTime
- );
- }
+ MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
+ 'api.' . $this->mModule->getModuleName() . '.executeTiming', 1000 * $runTime
+ );
} catch ( Exception $e ) {
$this->handleException( $e );
$this->logRequest( microtime( true ) - $t, $e );
$config = $this->getConfig();
$class = preg_replace( '#^Wikimedia\\\Rdbms\\\#', '', get_class( $e ) );
$code = 'internal_api_error_' . $class;
- if ( ( $e instanceof DBQueryError ) && !$config->get( 'ShowSQLErrors' ) ) {
- $params = [ 'apierror-databaseerror', WebRequest::getRequestId() ];
- } else {
+ if ( $config->get( 'ShowExceptionDetails' ) ) {
if ( $e instanceof ILocalizedException ) {
$msg = $e->getMessageObject();
} elseif ( $e instanceof MessageSpecifier ) {
$msg = wfEscapeWikiText( $e->getMessage() );
}
$params = [ 'apierror-exceptioncaught', WebRequest::getRequestId(), $msg ];
+ } else {
+ $params = [ 'apierror-exceptioncaughttype', WebRequest::getRequestId(), get_class( $e ) ];
}
+
$messages[] = ApiMessage::create( $params, $code );
}
return $messages;
)
);
} else {
- if ( $config->get( 'ShowExceptionDetails' ) &&
- ( !$e instanceof DBError || $config->get( 'ShowDBErrorBacktrace' ) )
- ) {
+ if ( $config->get( 'ShowExceptionDetails' ) ) {
$result->addContentValue(
$path,
'trace',