jenkins-bot has submitted this change and it was merged.

Change subject: Made all API modules use ApiErrorReporter
......................................................................


Made all API modules use ApiErrorReporter

In some places it was better to use dieError with a hard
coded message even though an exception was available.

Bug: 64874
Change-Id: I30e1413233112e5c4f95653122feddc97eb6aa3a
---
M repo/includes/api/ApiErrorReporter.php
M repo/includes/api/ApiWikibase.php
M repo/includes/api/CreateClaim.php
M repo/includes/api/EditEntity.php
M repo/includes/api/FormatSnakValue.php
M repo/includes/api/GetClaims.php
M repo/includes/api/GetEntities.php
M repo/includes/api/LinkTitles.php
M repo/includes/api/MergeItems.php
M repo/includes/api/ParseValue.php
M repo/includes/api/RemoveClaims.php
M repo/includes/api/RemoveQualifiers.php
M repo/includes/api/RemoveReferences.php
M repo/includes/api/SetAliases.php
M repo/includes/api/SetClaim.php
M repo/includes/api/SetClaimValue.php
M repo/includes/api/SetQualifier.php
M repo/includes/api/SetReference.php
M repo/includes/api/SetSiteLink.php
19 files changed, 111 insertions(+), 111 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/api/ApiErrorReporter.php 
b/repo/includes/api/ApiErrorReporter.php
index 8fdac4c..6d2e0a1 100644
--- a/repo/includes/api/ApiErrorReporter.php
+++ b/repo/includes/api/ApiErrorReporter.php
@@ -113,7 +113,7 @@
         * If possible, a localized error message based on the exception is
         * included in the error sent to the client. Localization of errors
         * is attempted using the ExceptionLocalizer service provided to the
-        * constructor. If that fails, dieUSage() is called, which in turn
+        * constructor. If that fails, dieUsage() is called, which in turn
         * attempts localization based on the error code.
         *
         * @see ApiBase::dieUsage()
@@ -148,7 +148,7 @@
         * If possible, a localized error message based on the exception is
         * included in the error sent to the client. Localization of errors
         * is attempted using the ExceptionLocalizer service provided to the
-        * constructor. If that fails, dieUSage() is called, which in turn
+        * constructor. If that fails, dieUsage() is called, which in turn
         * attempts localization based on the error code.
         *
         * @see ApiBase::dieUsage()
@@ -245,7 +245,7 @@
        }
 
        /**
-        * Throws a UsageException by calling $this->apiModule->dieUsage().
+        * Throws a UsageException by calling ApiBase::dieUsage().
         *
         * @see ApiBase::dieUsage()
         *
@@ -257,7 +257,7 @@
         * @throws LogicException
         */
        protected function throwUsageException( $description, $errorCode, 
$httpRespCode = 0, $extradata = null ) {
-               $this->apiModule->dieUsage( $description, $errorCode, 
$httpRespCode, $extradata );
+               $this->apiModule->getMain()->dieUsage( $description, 
$errorCode, $httpRespCode, $extradata );
 
                throw new LogicException( 'UsageException not thrown' );
        }
diff --git a/repo/includes/api/ApiWikibase.php 
b/repo/includes/api/ApiWikibase.php
index a8ddaab..4e65874 100644
--- a/repo/includes/api/ApiWikibase.php
+++ b/repo/includes/api/ApiWikibase.php
@@ -518,15 +518,15 @@
         * @deprecated since 0.5, use dieError(), dieException() or the
         * methods in $this->apiErrorReporter instead.
         *
-        * @todo: Remove all usages of this!
-        *
         * @param string $description
         * @param string $errorCode
         * @param int $httpRespCode
         * @param null $extradata
         */
        public function dieUsage( $description, $errorCode, $httpRespCode = 0, 
$extradata = null ) {
-               //NOTE: This is just here for the @deprecated flag above.
+               //NOTE: This is just here for the wfDeprecated call and the 
@deprecated flag above.
+               wfDeprecated( __METHOD__ );
+
                parent::dieUsage( $description, $errorCode, $httpRespCode, 
$extradata );
        }
 
diff --git a/repo/includes/api/CreateClaim.php 
b/repo/includes/api/CreateClaim.php
index e2f2453..7cad798 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -57,7 +57,7 @@
 
                $propertyId = 
$this->claimModificationHelper->getEntityIdFromString( $params['property'] );
                if( !$propertyId instanceof PropertyId ){
-                       $this->dieUsage(
+                       $this->dieError(
                                $propertyId->getSerialization() . ' does not 
appear to be a property ID',
                                'param-illegal'
                        );
@@ -93,19 +93,19 @@
        protected function validateParameters( array $params ) {
                if ( $params['snaktype'] == 'value' XOR isset( $params['value'] 
) ) {
                        if ( $params['snaktype'] == 'value' ) {
-                               $this->dieUsage( 'A value needs to be provided 
when creating a claim with PropertyValueSnak snak', 'param-missing' );
+                               $this->dieError( 'A value needs to be provided 
when creating a claim with PropertyValueSnak snak', 'param-missing' );
                        }
                        else {
-                               $this->dieUsage( 'You cannot provide a value 
when creating a claim with no PropertyValueSnak as main snak', 'param-illegal' 
);
+                               $this->dieError( 'You cannot provide a value 
when creating a claim with no PropertyValueSnak as main snak', 'param-illegal' 
);
                        }
                }
 
                if ( !isset( $params['property'] ) ) {
-                       $this->dieUsage( 'A property ID needs to be provided 
when creating a claim with a Snak', 'param-missing' );
+                       $this->dieError( 'A property ID needs to be provided 
when creating a claim with a Snak', 'param-missing' );
                }
 
                if ( isset( $params['value'] ) && \FormatJson::decode( 
$params['value'], true ) == null ) {
-                       $this->dieUsage( 'Could not decode snak value', 
'invalid-snak' );
+                       $this->dieError( 'Could not decode snak value', 
'invalid-snak' );
                }
        }
 
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 874a6c8..b54e031 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -130,7 +130,7 @@
                try {
                        return $entityFactory->newEmpty( $type );
                } catch ( InvalidArgumentException $e ) {
-                       $this->dieUsage( "No such entity type: '$type'", 
'no-such-entity-type' );
+                       $this->dieError( "No such entity type: '$type'", 
'no-such-entity-type' );
                }
 
                throw new LogicException( 'ApiBase::dieUsage did not throw a 
UsageException' );
@@ -146,13 +146,13 @@
                $hasSitelinkPart = ( isset( $params['site'] ) || isset( 
$params['title'] ) );
 
                if ( !( $hasId XOR $hasSitelink XOR $hasNew ) ) {
-                       $this->dieUsage( 'Either provide the item "id" or pairs 
of "site" and "title" or a "new" type for an entity' , 'param-missing' );
+                       $this->dieError( 'Either provide the item "id" or pairs 
of "site" and "title" or a "new" type for an entity' , 'param-missing' );
                }
                if( $hasId && $hasSitelink ){
-                       $this->dieUsage( "Parameter 'id' and 'site', 'title' 
combination are not allowed to be both set in the same request", 
'param-illegal' );
+                       $this->dieError( "Parameter 'id' and 'site', 'title' 
combination are not allowed to be both set in the same request", 
'param-illegal' );
                }
                if( ( $hasId || $hasSitelinkPart ) && $hasNew ){
-                       $this->dieUsage( "Parameters 'id', 'site', 'title' and 
'new' are not allowed to be both set in the same request", 'param-illegal' );
+                       $this->dieError( "Parameters 'id', 'site', 'title' and 
'new' are not allowed to be both set in the same request", 'param-illegal' );
                }
        }
 
@@ -173,7 +173,7 @@
                                $latestRevision = 
$this->entityLookup->getLatestRevisionId( $entity->getId() );
                                if( !$baseRevId === $latestRevision ) {
                                        wfProfileOut( __METHOD__ );
-                                       $this->dieUsage(
+                                       $this->dieError(
                                                'Tried to clear entity using 
baserevid of entity not equal to current revision',
                                                'editconflict'
                                        );
@@ -187,7 +187,7 @@
                if( !$exists && $entity instanceof Property ){
                        if ( !isset( $data['datatype'] ) ) {
                                wfProfileOut( __METHOD__ );
-                               $this->dieUsage( 'No datatype given', 
'param-illegal' );
+                               $this->dieError( 'No datatype given', 
'param-illegal' );
                        } else {
                                $entity->setDataTypeId( $data['datatype'] );
                        }
@@ -246,7 +246,7 @@
 
                if ( array_key_exists( 'sitelinks', $data ) ) {
                        if ( $entity->getType() !== Item::ENTITY_TYPE ) {
-                               $this->dieUsage( "Non Items can not have 
sitelinks", 'not-recognized' );
+                               $this->dieError( "Non Items can not have 
sitelinks", 'not-recognized' );
                        }
 
                        $changeOps->add( $this->getSiteLinksChangeOps( 
$data['sitelinks'], $entity ) );
@@ -270,7 +270,7 @@
                $labelChangeOps = array();
 
                if ( !is_array( $labels ) ) {
-                       $this->dieUsage( "List of labels must be an array", 
'not-recognized-array' );
+                       $this->dieError( "List of labels must be an array", 
'not-recognized-array' );
                }
 
                foreach ( $labels as $langCode => $arg ) {
@@ -300,7 +300,7 @@
                $descriptionChangeOps = array();
 
                if ( !is_array( $descriptions ) ) {
-                       $this->dieUsage( "List of descriptions must be an 
array", 'not-recognized-array' );
+                       $this->dieError( "List of descriptions must be an 
array", 'not-recognized-array' );
                }
 
                foreach ( $descriptions as $langCode => $arg ) {
@@ -328,7 +328,7 @@
         */
        protected function getAliasesChangeOps( $aliases ) {
                if ( !is_array( $aliases ) ) {
-                       $this->dieUsage( "List of aliases must be an array", 
'not-recognized-array' );
+                       $this->dieError( "List of aliases must be an array", 
'not-recognized-array' );
                }
 
                $indexedAliases = $this->getIndexedAliases( $aliases );
@@ -400,7 +400,7 @@
                $siteLinksChangeOps = array();
 
                if ( !is_array( $siteLinks ) ) {
-                       $this->dieUsage( "List of sitelinks must be an array", 
'not-recognized-array' );
+                       $this->dieError( "List of sitelinks must be an array", 
'not-recognized-array' );
                }
 
                $sites = $this->siteLinkTargetProvider->getSiteList( 
$this->siteLinkGroups );
@@ -416,7 +416,7 @@
                        if ( $sites->hasSite( $globalSiteId ) ) {
                                $linkSite = $sites->getSite( $globalSiteId );
                        } else {
-                               $this->dieUsage( "There is no site for global 
site id '$globalSiteId'", 'no-such-site' );
+                               $this->dieError( "There is no site for global 
site id '$globalSiteId'", 'no-such-site' );
                        }
                        /** @var Site $linkSite */
 
@@ -431,7 +431,7 @@
                                        $linkPage = 
$linkSite->normalizePageName( $this->stringNormalizer->trimWhitespace( 
$arg['title'] ) );
 
                                        if ( $linkPage === false ) {
-                                               $this->dieUsage(
+                                               $this->dieError(
                                                        "The external client 
site did not provide page information for site '{$globalSiteId}'",
                                                        'no-external-page' );
                                        }
@@ -439,7 +439,7 @@
                                        $linkPage = null;
 
                                        if ( !$entity->hasLinkToSite( 
$globalSiteId ) ) {
-                                               $this->dieUsage( "Cannot modify 
badges: sitelink to '{$globalSiteId}' doesn't exist", 'no-such-sitelink' );
+                                               $this->dieError( "Cannot modify 
badges: sitelink to '{$globalSiteId}' doesn't exist", 'no-such-sitelink' );
                                        }
                                }
 
@@ -458,7 +458,7 @@
         */
        protected function getClaimsChangeOps( $claims ) {
                if ( !is_array( $claims ) ) {
-                       $this->dieUsage( "List of claims must be an array", 
'not-recognized-array' );
+                       $this->dieError( "List of claims must be an array", 
'not-recognized-array' );
                }
                $changeOps = array();
 
@@ -496,9 +496,9 @@
                                        $claim = 
$unserializer->newFromSerialization( $claimArray );
                                        assert( $claim instanceof Claim );
                                } catch ( IllegalValueException 
$illegalValueException ) {
-                                       $this->dieUsage( 
$illegalValueException->getMessage(), 'invalid-claim' );
+                                       $this->dieException( 
$illegalValueException, 'invalid-claim' );
                                } catch ( MWException $mwException ) {
-                                       $this->dieUsage( 
$mwException->getMessage(), 'invalid-claim' );
+                                       $this->dieException( $mwException, 
'invalid-claim' );
                                }
                                /**      @var $claim Claim  */
 
@@ -522,7 +522,7 @@
                                if( array_key_exists( 'id', $claimArray ) ){
                                        $opsToReturn[] = 
$this->claimChangeOpFactory->newRemoveClaimOp( $claimArray['id'] );
                                } else {
-                                       $this->dieUsage( 'Cannot remove a claim 
with no GUID', 'invalid-claim' );
+                                       $this->dieError( 'Cannot remove a claim 
with no GUID', 'invalid-claim' );
                                }
                        }
                }
@@ -550,7 +550,7 @@
        private function validateDataParameter( $params ) {
                if ( !isset( $params['data'] ) ) {
                        wfProfileOut( __METHOD__ );
-                       $this->dieUsage( 'No data to operate upon', 'no-data' );
+                       $this->dieError( 'No data to operate upon', 'no-data' );
                }
        }
 
@@ -601,22 +601,22 @@
         */
        protected function checkValidJson( $data, array $allowedProps ) {
                if ( is_null( $data ) ) {
-                       $this->dieUsage( 'Invalid json: The supplied JSON 
structure could not be parsed or '
+                       $this->dieError( 'Invalid json: The supplied JSON 
structure could not be parsed or '
                                . 'recreated as a valid structure' , 
'invalid-json' );
                }
 
                // NOTE: json_decode will decode any JS literal or structure, 
not just objects!
                if ( !is_array( $data ) ) {
-                       $this->dieUsage( 'Top level structure must be a JSON 
object', 'not-recognized-array' );
+                       $this->dieError( 'Top level structure must be a JSON 
object', 'not-recognized-array' );
                }
 
                foreach ( $data as $prop => $args ) {
                        if ( !is_string( $prop ) ) { // NOTE: catch json_decode 
returning an indexed array (list)
-                               $this->dieUsage( 'Top level structure must be a 
JSON object, (no keys found)', 'not-recognized-string' );
+                               $this->dieError( 'Top level structure must be a 
JSON object, (no keys found)', 'not-recognized-string' );
                        }
 
                        if ( !in_array( $prop, $allowedProps ) ) {
-                               $this->dieUsage( "Unknown key in json: $prop", 
'not-recognized' );
+                               $this->dieError( "Unknown key in json: $prop", 
'not-recognized' );
                        }
                }
        }
@@ -628,7 +628,7 @@
        protected function checkPageIdProp( $data, $title ) {
                if ( isset( $data['pageid'] )
                        && ( is_object( $title ) ? $title->getArticleID() !== 
$data['pageid'] : true ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                'Illegal field used in call, "pageid", must 
either be correct or not given',
                                'param-illegal'
                        );
@@ -643,7 +643,7 @@
                // not completely convinced that we can use title to get the 
namespace in this case
                if ( isset( $data['ns'] )
                        && ( is_object( $title ) ? $title->getNamespace() !== 
$data['ns'] : true ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                'Illegal field used in call: "namespace", must 
either be correct or not given',
                                'param-illegal'
                        );
@@ -657,7 +657,7 @@
        protected function checkTitleProp( $data, $title ) {
                if ( isset( $data['title'] )
                        && ( is_object( $title ) ? $title->getPrefixedText() 
!== $data['title'] : true ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                'Illegal field used in call: "title", must 
either be correct or not given',
                                'param-illegal'
                        );
@@ -671,7 +671,7 @@
        protected function checkRevisionProp( $data, $revisionId ) {
                if ( isset( $data['lastrevid'] )
                        && ( is_int( $revisionId ) ? $revisionId !== 
$data['lastrevid'] : true ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                'Illegal field used in call: "lastrevid", must 
either be correct or not given',
                                'param-illegal'
                        );
@@ -681,7 +681,7 @@
        private function checkEntityId( $data, EntityId $entityId = null ) {
                if ( isset( $data['id'] ) ) {
                        if ( !$entityId ) {
-                               $this->dieUsage(
+                               $this->dieError(
                                        'Illegal field used in call: "id", must 
not be given when creating a new entity',
                                        'param-illegal'
                                );
@@ -689,7 +689,7 @@
 
                        $dataId = $this->idParser->parse( $data['id'] );
                        if( !$entityId->equals( $dataId ) ) {
-                               $this->dieUsage(
+                               $this->dieError(
                                        'Invalid field used in call: "id", must 
match id parameter',
                                        'param-invalid'
                                );
@@ -700,7 +700,7 @@
        private function checkEntityType( $data, Entity $entity ) {
                if ( isset( $data['type'] )
                        && $entity->getType() !== $data['type'] ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                'Invalid field used in call: "type", must match 
type associated with id',
                                'param-invalid'
                        );
@@ -829,29 +829,29 @@
         */
        public function validateMultilangArgs( $arg, $langCode ) {
                if ( !is_array( $arg ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                "An array was expected, but not found in the 
json for the langCode {$langCode}" ,
                                'not-recognized-array' );
                }
                if ( !is_string( $arg['language'] ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                "A string was expected, but not found in the 
json for the langCode {$langCode} and argument 'language'" ,
                                'not-recognized-string' );
                }
                if ( !is_numeric( $langCode ) ) {
                        if ( $langCode !== $arg['language'] ) {
-                               $this->dieUsage(
+                               $this->dieError(
                                        "inconsistent language: {$langCode} is 
not equal to {$arg['language']}",
                                        'inconsistent-language' );
                        }
                }
                if ( isset( $this->validLanguageCodes ) && !array_key_exists( 
$arg['language'], $this->validLanguageCodes ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                "unknown language: {$arg['language']}",
                                'not-recognized-language' );
                }
                if ( !array_key_exists( 'remove', $arg ) && !is_string( 
$arg['value'] ) ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                "A string was expected, but not found in the 
json for the langCode {$langCode} and argument 'value'" ,
                                'not-recognized-string' );
                }
@@ -866,29 +866,29 @@
         */
        public function checkSiteLinks( $arg, $siteCode, SiteList &$sites = 
null ) {
                if ( !is_array( $arg ) ) {
-                       $this->dieUsage( 'An array was expected, but not found' 
, 'not-recognized-array' );
+                       $this->dieError( 'An array was expected, but not found' 
, 'not-recognized-array' );
                }
                if ( !is_string( $arg['site'] ) ) {
-                       $this->dieUsage( 'A string was expected, but not found' 
, 'not-recognized-string' );
+                       $this->dieError( 'A string was expected, but not found' 
, 'not-recognized-string' );
                }
                if ( !is_numeric( $siteCode ) ) {
                        if ( $siteCode !== $arg['site'] ) {
-                               $this->dieUsage( "inconsistent site: 
{$siteCode} is not equal to {$arg['site']}", 'inconsistent-site' );
+                               $this->dieError( "inconsistent site: 
{$siteCode} is not equal to {$arg['site']}", 'inconsistent-site' );
                        }
                }
                if ( isset( $sites ) && !$sites->hasSite( $arg['site'] ) ) {
-                       $this->dieUsage( "unknown site: {$arg['site']}", 
'not-recognized-site' );
+                       $this->dieError( "unknown site: {$arg['site']}", 
'not-recognized-site' );
                }
                if ( isset( $arg['title'] ) && !is_string( $arg['title'] ) ) {
-                       $this->dieUsage( 'A string was expected, but not found' 
, 'not-recognized-string' );
+                       $this->dieError( 'A string was expected, but not found' 
, 'not-recognized-string' );
                }
                if ( isset( $arg['badges'] ) ) {
                        if ( !is_array( $arg['badges'] ) ) {
-                               $this->dieUsage( 'Badges: an array was 
expected, but not found' , 'not-recognized-array' );
+                               $this->dieError( 'Badges: an array was 
expected, but not found' , 'not-recognized-array' );
                        } else {
                                foreach ( $arg['badges'] as $badge ) {
                                        if ( !is_string( $badge ) ) {
-                                               $this->dieUsage( 'Badges: a 
string was expected, but not found' , 'not-recognized-string' );
+                                               $this->dieError( 'Badges: a 
string was expected, but not found' , 'not-recognized-string' );
                                        }
                                }
                        }
diff --git a/repo/includes/api/FormatSnakValue.php 
b/repo/includes/api/FormatSnakValue.php
index e6fde9a..2e3e9e6 100644
--- a/repo/includes/api/FormatSnakValue.php
+++ b/repo/includes/api/FormatSnakValue.php
@@ -117,14 +117,14 @@
                $data = \FormatJson::decode( $json, true );
 
                if ( !is_array( $data ) ) {
-                       $this->dieUsage( 'Failed to decode datavalue', 
'baddatavalue' );
+                       $this->dieError( 'Failed to decode datavalue', 
'baddatavalue' );
                }
 
                try {
                        $value = $this->getValueFactory()->newFromArray( $data 
);
                        return $value;
                } catch ( IllegalValueException $ex ) {
-                       $this->dieUsage( $ex->getMessage(), 'baddatavalue' );
+                       $this->dieException( $ex, 'baddatavalue' );
                }
 
                throw new LogicException( 'ApiBase::dieUsage did not throw a 
UsageException' );
diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php
index 00b68e5..6a79b16 100644
--- a/repo/includes/api/GetClaims.php
+++ b/repo/includes/api/GetClaims.php
@@ -89,7 +89,7 @@
 
        protected function validateParameters( array $params ) {
                if ( !isset( $params['entity'] ) && !isset( $params['claim'] ) 
) {
-                       $this->dieUsage( 'Either the entity parameter or the 
claim parameter need to be set', 'param-missing' );
+                       $this->dieError( 'Either the entity parameter or the 
claim parameter need to be set', 'param-missing' );
                }
        }
 
@@ -187,7 +187,7 @@
                        $entityId = $this->getEntityIdFromClaimGuid( 
$params['claim'] );
 
                        if( isset( $params['entity'] ) && $entityId !== 
$params['entity'] ) {
-                               $this->dieUsage( 'If both entity id and claim 
key are provided they need to point to the same entity', 'param-illegal' );
+                               $this->dieError( 'If both entity id and claim 
key are provided they need to point to the same entity', 'param-illegal' );
                        }
                } else {
                        $claimGuid = null;
@@ -199,7 +199,7 @@
 
        protected function getEntityIdFromClaimGuid( $claimGuid ) {
                if ( $this->claimGuidValidator->validateFormat( $claimGuid ) 
=== false ) {
-                       $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
+                       $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
                return $this->claimGuidParser->parse( $claimGuid 
)->getEntityId()->getSerialization();
diff --git a/repo/includes/api/GetEntities.php 
b/repo/includes/api/GetEntities.php
index b9c9415..92d5a32 100644
--- a/repo/includes/api/GetEntities.php
+++ b/repo/includes/api/GetEntities.php
@@ -75,7 +75,7 @@
 
                if ( !isset( $params['ids'] ) && ( empty( $params['sites'] ) || 
empty( $params['titles'] ) ) ) {
                        wfProfileOut( __METHOD__ );
-                       $this->dieUsage(
+                       $this->dieError(
                                'Either provide the item "ids" or pairs of 
"sites" and "titles" for corresponding pages',
                                'param-missing'
                        );
@@ -123,7 +123,7 @@
                                        $ids[] = $this->idParser->parse( $id );
                                } catch( EntityIdParsingException $e ) {
                                        wfProfileOut( __METHOD__ );
-                                       $this->dieUsage( "Invalid id: $id", 
'no-such-entity' );
+                                       $this->dieError( "Invalid id: $id", 
'no-such-entity' );
                                }
                        }
                }
diff --git a/repo/includes/api/LinkTitles.php b/repo/includes/api/LinkTitles.php
index 47caf29..2898632 100644
--- a/repo/includes/api/LinkTitles.php
+++ b/repo/includes/api/LinkTitles.php
@@ -122,12 +122,12 @@
                elseif ( $fromId->equals( $toId ) ) {
                        // no-op
                        wfProfileOut( __METHOD__ );
-                       $this->dieUsage( 'Common item detected, sitelinks are 
both on the same item', 'common-item' );
+                       $this->dieError( 'Common item detected, sitelinks are 
both on the same item', 'common-item' );
                }
                else {
                        // dissimilar items
                        wfProfileOut( __METHOD__ );
-                       $this->dieUsage( 'No common item detected, unable to 
link titles' , 'no-common-item' );
+                       $this->dieError( 'No common item detected, unable to 
link titles' , 'no-common-item' );
                }
 
                $this->getResultBuilder()->addSiteLinks( $return, 'entity' );
@@ -142,7 +142,7 @@
         */
        private function validatePage( $page, $label ) {
                if ( $page === false ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                "The external client site did not provide page 
information for the {$label} page" ,
                                'no-external-page'
                        );
@@ -182,11 +182,11 @@
         */
        protected function validateParameters( array $params ) {
                if ( $params['fromsite'] === $params['tosite'] ) {
-                       $this->dieUsage( 'The from site can not match the to 
site' , 'param-illegal' );
+                       $this->dieError( 'The from site can not match the to 
site' , 'param-illegal' );
                }
 
                if( !( strlen( $params['fromtitle'] ) > 0) || !( strlen( 
$params['totitle'] ) > 0) ){
-                       $this->dieUsage( 'The from title and to title must have 
a value' , 'param-illegal' );
+                       $this->dieError( 'The from title and to title must have 
a value' , 'param-illegal' );
                }
        }
 
diff --git a/repo/includes/api/MergeItems.php b/repo/includes/api/MergeItems.php
index 7cb3f74..b36dec5 100644
--- a/repo/includes/api/MergeItems.php
+++ b/repo/includes/api/MergeItems.php
@@ -83,7 +83,7 @@
                $status->merge( $this->checkPermissions( $fromEntity, $user, 
$params ) );
                $status->merge( $this->checkPermissions( $toEntity, $user, 
$params ) );
                if( !$status->isGood() ){
-                       $this->dieUsage( $status->getMessage(), 
'permissiondenied');
+                       $this->dieStatus( $status, 'permissiondenied' );
                }
 
                $ignoreConflicts = $this->getIgnoreConflicts( $params );
@@ -102,10 +102,10 @@
                        $changeOps->apply();
                }
                catch( InvalidArgumentException $e ) {
-                       $this->dieUsage( $e->getMessage(), 'param-invalid' );
+                       $this->dieException( $e, 'param-invalid' );
                }
                catch( ChangeOpException $e ) {
-                       $this->dieUsage( $e->getMessage(), 'failed-save' ); 
//FIXME: change to modification-failed
+                       $this->dieException( $e, 'failed-save' ); //FIXME: 
change to modification-failed
                }
 
                $this->attemptSaveMerge( $fromEntity, $toEntity, $params );
@@ -129,7 +129,7 @@
                        return $this->entityLookup->getEntityRevision( 
$entityId );
                }
                catch ( EntityIdParsingException $e ){
-                       $this->dieUsage( 'You must provide valid ids' , 
'param-invalid' );
+                       $this->dieError( 'You must provide valid ids' , 
'param-invalid' );
                }
                return null;
        }
@@ -140,11 +140,11 @@
         */
        private function validateEntity( $fromEntity, $toEntity) {
                if ( !( $fromEntity instanceof Item && $toEntity instanceof 
Item ) ) {
-                       $this->dieUsage( 'One or more of the entities are not 
items', 'not-item' );
+                       $this->dieError( 'One or more of the entities are not 
items', 'not-item' );
                }
 
                if( $toEntity->getId()->equals( $fromEntity->getId() ) ){
-                       $this->dieUsage( 'You must provide unique ids' , 
'param-invalid' );
+                       $this->dieError( 'You must provide unique ids' , 
'param-invalid' );
                }
        }
 
@@ -153,7 +153,7 @@
         */
        private function validateParams( array $params ) {
                if ( empty( $params['fromid'] ) || empty( $params['toid'] ) ){
-                       $this->dieUsage( 'You must provide a fromid and a toid' 
, 'param-missing' );
+                       $this->dieError( 'You must provide a fromid and a toid' 
, 'param-missing' );
                }
        }
 
diff --git a/repo/includes/api/ParseValue.php b/repo/includes/api/ParseValue.php
index df341aa..59549ad 100644
--- a/repo/includes/api/ParseValue.php
+++ b/repo/includes/api/ParseValue.php
@@ -136,7 +136,7 @@
                        $options = \FormatJson::decode( $optionsParam, true );
 
                        if ( !is_array( $options ) ) {
-                               $this->dieUsage( 'Malformed options parameter', 
'malformed-options' );
+                               $this->dieError( 'Malformed options parameter', 
'malformed-options' );
                        }
 
                        foreach ( $options as $name => $value ) {
diff --git a/repo/includes/api/RemoveClaims.php 
b/repo/includes/api/RemoveClaims.php
index 347b62f..54dc85e 100644
--- a/repo/includes/api/RemoveClaims.php
+++ b/repo/includes/api/RemoveClaims.php
@@ -64,7 +64,7 @@
                try {
                        $changeOps->apply( $entity, $summary );
                } catch ( ChangeOpException $e ) {
-                       $this->dieUsage( $e->getMessage(), 'failed-save' );
+                       $this->dieException( $e, 'failed-save' );
                }
 
                $this->saveChanges( $entity, $summary );
@@ -88,20 +88,20 @@
 
                foreach ( $params['claim'] as $guid ) {
                        if ( 
!$this->claimModificationHelper->validateClaimGuid( $guid ) ) {
-                               $this->dieUsage( "Invalid claim guid $guid" , 
'invalid-guid' );
+                               $this->dieError( "Invalid claim guid $guid" , 
'invalid-guid' );
                        }
 
                        if ( is_null( $entityId ) ) {
                                $entityId = $this->claimGuidParser->parse( 
$guid )->getEntityId();
                        } else {
                                if ( !$this->claimGuidParser->parse( $guid 
)->getEntityId()->equals( $entityId ) ) {
-                                       $this->dieUsage( 'All claims must 
belong to the same entity' , 'invalid-guid' );
+                                       $this->dieError( 'All claims must 
belong to the same entity' , 'invalid-guid' );
                                }
                        }
                }
 
                if ( is_null( $entityId ) ) {
-                       $this->dieUsage( 'Could not find an entity for the 
claims' , 'invalid-guid' );
+                       $this->dieError( 'Could not find an entity for the 
claims' , 'invalid-guid' );
                }
 
                return $entityId ;
@@ -120,7 +120,7 @@
 
                foreach ( $guids as $guid) {
                        if ( !$claims->hasClaimWithGuid( $guid ) ) {
-                               $this->dieUsage( "Claim with guid $guid not 
found" , 'invalid-guid' );
+                               $this->dieError( "Claim with guid $guid not 
found" , 'invalid-guid' );
                        }
                }
        }
diff --git a/repo/includes/api/RemoveQualifiers.php 
b/repo/includes/api/RemoveQualifiers.php
index 44096e2..492611a 100644
--- a/repo/includes/api/RemoveQualifiers.php
+++ b/repo/includes/api/RemoveQualifiers.php
@@ -67,7 +67,7 @@
                try {
                        $changeOps->apply( $entity, $summary );
                } catch ( ChangeOpException $e ) {
-                       $this->dieUsage( $e->getMessage(), 'failed-save' );
+                       $this->dieException( $e, 'failed-save' );
                }
 
                $this->saveChanges( $entity, $summary );
@@ -83,7 +83,7 @@
         */
        protected function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['claim'] ) ) ) {
-                       $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
+                       $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
        }
 
@@ -119,7 +119,7 @@
 
                foreach ( array_unique( $params['qualifiers'] ) as 
$qualifierHash ) {
                        if ( !$qualifiers->hasSnakHash( $qualifierHash ) ) {
-                               $this->dieUsage( 'Invalid snak hash', 
'no-such-qualifier' );
+                               $this->dieError( 'Invalid snak hash', 
'no-such-qualifier' );
                        }
                        $hashes[] = $qualifierHash;
                }
diff --git a/repo/includes/api/RemoveReferences.php 
b/repo/includes/api/RemoveReferences.php
index 986a318..a1ce4bb 100644
--- a/repo/includes/api/RemoveReferences.php
+++ b/repo/includes/api/RemoveReferences.php
@@ -60,7 +60,7 @@
                $claim = $this->claimModificationHelper->getClaimFromEntity( 
$claimGuid, $entity );
 
                if ( ! ( $claim instanceof Statement ) ) {
-                       $this->dieUsage( 'The referenced claim is not a 
statement and thus cannot have references', 'not-statement' );
+                       $this->dieError( 'The referenced claim is not a 
statement and thus cannot have references', 'not-statement' );
                }
 
                $referenceHashes = $this->getReferenceHashesFromParams( 
$params, $claim );
@@ -71,7 +71,7 @@
                try {
                        $changeOps->apply( $entity, $summary );
                } catch ( ChangeOpException $e ) {
-                       $this->dieUsage( $e->getMessage(), 'failed-save' );
+                       $this->dieException( $e, 'failed-save' );
                }
 
                $this->saveChanges( $entity, $summary );
@@ -87,7 +87,7 @@
         */
        protected function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['statement'] ) ) ) {
-                       $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
+                       $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
        }
 
@@ -123,7 +123,7 @@
        
                foreach ( array_unique( $params['references'] ) as 
$referenceHash ) {
                        if ( !$references->hasReferenceHash( $referenceHash ) ) 
{
-                               $this->dieUsage( 'Invalid reference hash', 
'no-such-reference' );
+                               $this->dieError( 'Invalid reference hash', 
'no-such-reference' );
                        }
                        $hashes[] = $referenceHash;
                }
diff --git a/repo/includes/api/SetAliases.php b/repo/includes/api/SetAliases.php
index 43d6db5..927cfd2 100644
--- a/repo/includes/api/SetAliases.php
+++ b/repo/includes/api/SetAliases.php
@@ -75,7 +75,7 @@
                parent::validateParameters( $params );
 
                if ( !( ( !empty( $params['add'] ) || !empty( $params['remove'] 
) ) xor isset( $params['set'] ) ) ) {
-                       $this->dieUsage( "Parameters 'add' and 'remove' are not 
allowed to be set when parameter 'set' is provided" , 'invalid-list' );
+                       $this->dieError( "Parameters 'add' and 'remove' are not 
allowed to be set when parameter 'set' is provided" , 'invalid-list' );
                }
        }
 
@@ -83,7 +83,7 @@
         * @see ApiModifyEntity::createEntity()
         */
        protected function createEntity( array $params ) {
-               $this->dieUsage( 'Could not find an existing entity' , 
'no-such-entity' );
+               $this->dieError( 'Could not find an existing entity' , 
'no-such-entity' );
        }
 
        /**
diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php
index 139f763..977161d 100644
--- a/repo/includes/api/SetClaim.php
+++ b/repo/includes/api/SetClaim.php
@@ -61,7 +61,7 @@
 
                $guid = $claim->getGuid();
                if( $guid === null ){
-                       $this->dieUsage( 'GUID must be set when setting a 
claim', 'invalid-claim' );
+                       $this->dieError( 'GUID must be set when setting a 
claim', 'invalid-claim' );
                }
                $guid = $this->claimGuidParser->parse( $guid );
 
@@ -131,9 +131,9 @@
                        }
                        return $claim;
                } catch( InvalidArgumentException $invalidArgumentException ) {
-                       $this->dieUsage( 'Failed to get claim from claim 
Serialization ' . $invalidArgumentException->getMessage(), 'invalid-claim' );
+                       $this->dieError( 'Failed to get claim from claim 
Serialization ' . $invalidArgumentException->getMessage(), 'invalid-claim' );
                } catch( OutOfBoundsException $outOfBoundsException ) {
-                       $this->dieUsage( 'Failed to get claim from claim 
Serialization ' . $outOfBoundsException->getMessage(), 'invalid-claim' );
+                       $this->dieError( 'Failed to get claim from claim 
Serialization ' . $outOfBoundsException->getMessage(), 'invalid-claim' );
                }
 
                // Note: since dieUsage() never returns, this should be 
unreachable!
diff --git a/repo/includes/api/SetClaimValue.php 
b/repo/includes/api/SetClaimValue.php
index c81eedb..a36e88c 100644
--- a/repo/includes/api/SetClaimValue.php
+++ b/repo/includes/api/SetClaimValue.php
@@ -79,7 +79,7 @@
         */
        protected function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['claim'] ) ) ) {
-                       $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
+                       $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
        }
 
diff --git a/repo/includes/api/SetQualifier.php 
b/repo/includes/api/SetQualifier.php
index 9be79bb..2e21ac6 100644
--- a/repo/includes/api/SetQualifier.php
+++ b/repo/includes/api/SetQualifier.php
@@ -81,21 +81,21 @@
         */
        protected function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['claim'] ) ) ) {
-                       $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
+                       $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
 
                if ( !isset( $params['snakhash'] ) ) {
                        if ( !isset( $params['snaktype'] ) ) {
-                               $this->dieUsage( 'When creating a new qualifier 
(ie when not providing a snakhash) a snaktype should be specified', 
'param-missing' );
+                               $this->dieError( 'When creating a new qualifier 
(ie when not providing a snakhash) a snaktype should be specified', 
'param-missing' );
                        }
 
                        if ( !isset( $params['property'] ) ) {
-                               $this->dieUsage( 'When creating a new qualifier 
(ie when not providing a snakhash) a property should be specified', 
'param-missing' );
+                               $this->dieError( 'When creating a new qualifier 
(ie when not providing a snakhash) a property should be specified', 
'param-missing' );
                        }
                }
 
                if ( isset( $params['snaktype'] ) && $params['snaktype'] === 
'value' && !isset( $params['value'] ) ) {
-                       $this->dieUsage( 'When setting a qualifier that is a 
PropertyValueSnak, the value needs to be provided', 'param-missing' );
+                       $this->dieError( 'When setting a qualifier that is a 
PropertyValueSnak, the value needs to be provided', 'param-missing' );
                }
        }
 
@@ -107,7 +107,7 @@
         */
        protected function validateQualifierHash( Claim $claim, $qualifierHash 
) {
                if ( !$claim->getQualifiers()->hasSnakHash( $qualifierHash ) ) {
-                       $this->dieUsage( "Claim does not have a qualifier with 
the given hash" , 'no-such-qualifier' );
+                       $this->dieError( "Claim does not have a qualifier with 
the given hash" , 'no-such-qualifier' );
                }
        }
 
@@ -123,7 +123,7 @@
 
                $propertyId = 
$this->claimModificationHelper->getEntityIdFromString( $params['property'] );
                if( !$propertyId instanceof PropertyId ){
-                       $this->dieUsage(
+                       $this->dieError(
                                $propertyId->getSerialization() . ' does not 
appear to be a property ID',
                                'param-illegal'
                        );
diff --git a/repo/includes/api/SetReference.php 
b/repo/includes/api/SetReference.php
index 7100458..db705fa 100644
--- a/repo/includes/api/SetReference.php
+++ b/repo/includes/api/SetReference.php
@@ -64,7 +64,7 @@
                $claim = $this->claimModificationHelper->getClaimFromEntity( 
$params['statement'], $entity );
 
                if ( ! ( $claim instanceof Statement ) ) {
-                       $this->dieUsage( 'The referenced claim is not a 
statement and thus cannot have references', 'not-statement' );
+                       $this->dieError( 'The referenced claim is not a 
statement and thus cannot have references', 'not-statement' );
                }
 
                if ( isset( $params['reference'] ) ) {
@@ -101,7 +101,7 @@
         */
        protected function validateParameters( array $params ) {
                if ( !( $this->claimModificationHelper->validateClaimGuid( 
$params['statement'] ) ) ) {
-                       $this->dieUsage( 'Invalid claim guid' , 'invalid-guid' 
);
+                       $this->dieError( 'Invalid claim guid' , 'invalid-guid' 
);
                }
        }
 
@@ -113,7 +113,7 @@
         */
        protected function validateReferenceHash( Statement $claim, 
$referenceHash ) {
                if ( !$claim->getReferences()->hasReferenceHash( $referenceHash 
) ) {
-                       $this->dieUsage( "Claim does not have a reference with 
the given hash" , 'no-such-reference' );
+                       $this->dieError( "Claim does not have a reference with 
the given hash" , 'no-such-reference' );
                }
        }
 
@@ -128,7 +128,7 @@
                $rawArray = FormatJson::decode( $arrayParam, true );
 
                if ( !is_array( $rawArray ) || !count( $rawArray ) ) {
-                       $this->dieUsage( 'No array or invalid JSON given', 
'invalid-json' );
+                       $this->dieError( 'No array or invalid JSON given', 
'invalid-json' );
                }
 
                return $rawArray;
@@ -155,11 +155,11 @@
                try {
                        foreach( $snakOrder as $propertyId ) {
                                if ( !is_array( $rawSnaks[$propertyId] ) ) {
-                                       $this->dieUsage( 'Invalid snak JSON 
given', 'invalid-json' );
+                                       $this->dieError( 'Invalid snak JSON 
given', 'invalid-json' );
                                }
                                foreach ( $rawSnaks[$propertyId] as $rawSnak ) {
                                        if ( !is_array( $rawSnak ) ) {
-                                               $this->dieUsage( 'Invalid snak 
JSON given', 'invalid-json' );
+                                               $this->dieError( 'Invalid snak 
JSON given', 'invalid-json' );
                                        }
 
                                        $snak = 
$snakUnserializer->newFromSerialization( $rawSnak );
@@ -168,13 +168,13 @@
                        }
                } catch( InvalidArgumentException $invalidArgumentException ) {
                        // Handle Snak instantiation failures
-                       $this->dieUsage(
+                       $this->dieError(
                                'Failed to get reference from reference 
Serialization '
                                        . 
$invalidArgumentException->getMessage(),
                                'snak-instantiation-failure'
                        );
                } catch( OutOfBoundsException $outOfBoundsException ) {
-                       $this->dieUsage(
+                       $this->dieError(
                                'Failed to get reference from reference 
Serialization '
                                        . $outOfBoundsException->getMessage(),
                                'snak-instantiation-failure'
diff --git a/repo/includes/api/SetSiteLink.php 
b/repo/includes/api/SetSiteLink.php
index 9e4d537..f627a65 100644
--- a/repo/includes/api/SetSiteLink.php
+++ b/repo/includes/api/SetSiteLink.php
@@ -67,7 +67,7 @@
 
                // If we found anything then check if it is of the correct base 
class
                if ( !is_null( $entityRev ) && !( $entityRev->getEntity() 
instanceof Item ) ) {
-                       $this->dieUsage( 'The content on the found page is not 
of correct type', 'wrong-class' );
+                       $this->dieError( 'The content on the found page is not 
of correct type', 'wrong-class' );
                }
 
                return $entityRev;
@@ -81,7 +81,7 @@
 
                if ( !( $entity instanceof Item ) ) {
                        wfProfileOut( __METHOD__ );
-                       $this->dieUsage( "The given entity is not an item", 
"not-item" );
+                       $this->dieError( "The given entity is not an item", 
"not-item" );
                }
 
                $item = $entity;
@@ -106,7 +106,7 @@
                                $this->getResultBuilder()->addSiteLinks( array( 
$link ), 'entity', array( 'url' ) );
                        } else {
                                wfProfileOut( __METHOD__ );
-                               $this->dieUsage( "Cannot modify badges: 
sitelink to '{$params['linktitle']}' doesn't exist", 'no-such-sitelink' );
+                               $this->dieError( "Cannot modify badges: 
sitelink to '{$params['linktitle']}' doesn't exist", 'no-such-sitelink' );
                        }
                }
 
@@ -133,7 +133,7 @@
 
                        if ( $site === false ) {
                                wfProfileOut( __METHOD__ );
-                               $this->dieUsage( 'The supplied site identifier 
was not recognized' , 'not-recognized-siteid' );
+                               $this->dieError( 'The supplied site identifier 
was not recognized' , 'not-recognized-siteid' );
                        }
 
                        if ( isset( $params['linktitle'] ) ) {
@@ -141,7 +141,7 @@
 
                                if ( $page === false ) {
                                        wfProfileOut( __METHOD__ );
-                                       $this->dieUsage( 'The external client 
site did not provide page information' , 'no-external-page' );
+                                       $this->dieError( 'The external client 
site did not provide page information' , 'no-external-page' );
                                }
                        } else {
                                $page = null;

-- 
To view, visit https://gerrit.wikimedia.org/r/148622
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I30e1413233112e5c4f95653122feddc97eb6aa3a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: WikidataJenkins <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to