Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/240712

Change subject: Make RevisionBasedEntityLookup adhere to its interfaces contract
......................................................................

Make RevisionBasedEntityLookup adhere to its interfaces contract

Change-Id: I7f185228740d6d14a4a7940db15fe07c14920aa1
---
M lib/includes/store/RevisionBasedEntityLookup.php
1 file changed, 17 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/12/240712/1

diff --git a/lib/includes/store/RevisionBasedEntityLookup.php 
b/lib/includes/store/RevisionBasedEntityLookup.php
index 868fc89..9008a5d 100644
--- a/lib/includes/store/RevisionBasedEntityLookup.php
+++ b/lib/includes/store/RevisionBasedEntityLookup.php
@@ -5,6 +5,7 @@
 use Wikibase\DataModel\Entity\EntityDocument;
 use Wikibase\DataModel\Entity\EntityId;
 use Wikibase\DataModel\Services\Lookup\EntityLookup;
+use Wikibase\DataModel\Services\Lookup\EntityLookupException;
 
 /**
  * An implementation of EntityLookup based on an EntityRevisionLookup.
@@ -35,12 +36,18 @@
         *
         * @param EntityId $entityId
         *
-        * @throws StorageException
+        * @throws EntityLookupException
         * @return EntityDocument|null
         */
        public function getEntity( EntityId $entityId ) {
-               $revision = $this->lookup->getEntityRevision( $entityId );
-               return ( $revision === null ) ? null : $revision->getEntity();
+               try {
+                       $revision = $this->lookup->getEntityRevision( $entityId 
);
+               } catch ( \Exception $ex ) {
+                       // TODO: catch more specific exception once 
EntityRevisionLookup contract gets clarified
+                       throw new EntityLookupException( $entityId, null, $ex );
+               }
+
+               return $revision === null ? null : $revision->getEntity();
        }
 
        /**
@@ -48,12 +55,16 @@
         *
         * @param EntityId $entityId
         *
-        * @throws StorageException
+        * @throws EntityLookupException
         * @return bool
         */
        public function hasEntity( EntityId $entityId ) {
-               return $this->lookup->getLatestRevisionId( $entityId ) !== 
false;
-
+               try {
+                       return $this->lookup->getLatestRevisionId( $entityId ) 
!== false;
+               } catch ( \Exception $ex ) {
+                       // TODO: catch more specific exception once 
EntityRevisionLookup contract gets clarified
+                       throw new EntityLookupException( $entityId, null, $ex );
+               }
        }
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f185228740d6d14a4a7940db15fe07c14920aa1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

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

Reply via email to