Jeroen De Dauw has submitted this change and it was merged.

Change subject: InMemoryDataTypeLookup should throw PropertyNotFoundException
......................................................................


InMemoryDataTypeLookup should throw PropertyNotFoundException

...instead of OutOfBoundsException.

Change-Id: Ibb3e267cd00e2c88c8b461ef3a81d159571d14c1
---
M lib/includes/InMemoryDataTypeLookup.php
M lib/includes/PropertyDataTypeLookup.php
M lib/includes/PropertyNotFoundException.php
M lib/tests/phpunit/InMemoryDataTypeLookupTest.php
4 files changed, 8 insertions(+), 3 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/InMemoryDataTypeLookup.php 
b/lib/includes/InMemoryDataTypeLookup.php
index 61344f1..caf9418 100644
--- a/lib/includes/InMemoryDataTypeLookup.php
+++ b/lib/includes/InMemoryDataTypeLookup.php
@@ -70,7 +70,7 @@
                $numericId = $propertyId->getNumericId();
 
                if ( !array_key_exists( $numericId, $this->dataTypeIds ) ) {
-                       throw new OutOfBoundsException( "The DataType for 
property '$numericId' is not set" );
+                       throw new PropertyNotFoundException( $propertyId );
                }
        }
 
diff --git a/lib/includes/PropertyDataTypeLookup.php 
b/lib/includes/PropertyDataTypeLookup.php
index 7fe98e3..0273ad6 100644
--- a/lib/includes/PropertyDataTypeLookup.php
+++ b/lib/includes/PropertyDataTypeLookup.php
@@ -41,6 +41,7 @@
         * @param EntityId $propertyId
         *
         * @return string
+        * @throws PropertyNotFoundException
         */
        public function getDataTypeIdForProperty( EntityId $propertyId );
 
diff --git a/lib/includes/PropertyNotFoundException.php 
b/lib/includes/PropertyNotFoundException.php
index 2386f57..52d0534 100644
--- a/lib/includes/PropertyNotFoundException.php
+++ b/lib/includes/PropertyNotFoundException.php
@@ -33,9 +33,13 @@
 
        protected $propertyId;
 
-       public function __construct( EntityId $propertyId, $message = '', 
\Exception $previous = null ) {
+       public function __construct( EntityId $propertyId, $message = null, 
\Exception $previous = null ) {
                $this->propertyId = $propertyId;
 
+               if ( $message === null ) {
+                       $message = "Property not found: " . $propertyId;
+               }
+
                parent::__construct( $message, 0, $previous );
        }
 
diff --git a/lib/tests/phpunit/InMemoryDataTypeLookupTest.php 
b/lib/tests/phpunit/InMemoryDataTypeLookupTest.php
index 5e73c55..0583c2a 100644
--- a/lib/tests/phpunit/InMemoryDataTypeLookupTest.php
+++ b/lib/tests/phpunit/InMemoryDataTypeLookupTest.php
@@ -43,7 +43,7 @@
        public function testGetDataTypeForPropertyThatIsNotSet() {
                $lookup = new InMemoryDataTypeLookup();
 
-               $this->setExpectedException( 'OutOfBoundsException' );
+               $this->setExpectedException( 
'\Wikibase\Lib\PropertyNotFoundException' );
 
                $lookup->getDataTypeIdForProperty( new EntityId( 
Property::ENTITY_TYPE, 7201010 ) );
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb3e267cd00e2c88c8b461ef3a81d159571d14c1
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to