wmde/WikibaseDataModel — pull request #276 by GPHemsley (2014-11-09 20:12:57+00:00)
Title: Make exception error message style more uniform.

I audited the exception error messages and discovered that different throws often reported the same error differently. I've gone through and made the text more uniform (and hopefully clearer and more helpful for a debugger) for the most common of cases.

I've left the following cases as-is:
```
ByPropertyIdArray.php:88:	throw new RuntimeException( 'Index not build, call buildIndex first' );
ByPropertyIdArray.php:220:	throw new OutOfBoundsException( 'Object cannot be moved to ' . $toIndex );
ByPropertyIdArray.php:387:	throw new OutOfBoundsException( 'Object not present in array' );
ByPropertyIdArray.php:389:	throw new OutOfBoundsException( 'Specified index is out of bounds' );
ByPropertyIdArray.php:465:	throw new OutOfBoundsException( 'No objects featuring the object\'s property exist' );
Statement/Statement.php:100:	throw new InvalidArgumentException( 'Invalid rank specified for statement: ' . var_export( $rank, true ) );
LegacyIdInterpreter.php:38:	throw new InvalidArgumentException( 'Invalid entityType ' . $entityType );
SiteLinkList.php:52:	throw new InvalidArgumentException( 'Duplicate site id: ' . $link->getSiteId() );
Claim/Claims.php:77:	throw new InvalidArgumentException( 'Can\'t handle claims with no GUID set!' );
Claim/ClaimGuidParser.php:41:	throw new ClaimGuidParsingException( '$serialization does not have the correct number of parts' );
Entity/Diff/EntityPatcher.php:50:	throw new RuntimeException( 'Patching the provided types of entities is not supported' );
Entity/Diff/EntityDiffer.php:47:	throw new InvalidArgumentException( 'Can only diff two entities of the same type' );
Entity/Diff/EntityDiffer.php:58:	throw new RuntimeException( 'Diffing the provided types of entities is not supported' );
Entity/Item.php:251:	throw new InvalidArgumentException( 'Can\'t add a Claim without a GUID.' );
Entity/InMemoryDataTypeLookup.php:50:	throw new PropertyNotFoundException( $propertyId, "The DataType for property '$numericId' is not set" );
Entity/Entity.php:367:	throw new RuntimeException( 'Claims on entities are not supported any more.' );
Entity/EntityIdValue.php:67:	throw new IllegalValueException( 'Invalid EntityIdValue serialization.' );
Entity/EntityIdValue.php:147:	throw new IllegalValueException( "'entity-type' field required" );
Entity/EntityIdValue.php:151:	throw new IllegalValueException( "'numeric-id' field required" );
Entity/EntityIdValue.php:161:	throw new IllegalValueException( $ex->getMessage(), 0, $ex );
Entity/DispatchingEntityIdParser.php:48:	throw $this->newInvalidIdException( $idSerialization );
Entity/DispatchingEntityIdParser.php:74:	throw $this->newInvalidIdException( $idSerialization );
```

These could also be made more uniform, but there weren't enough instances for me to determine the best format of the message.

In addition, in doing this, I discovered a few places where code could be optimized or where typos could be fixed, but I did not change them.

I also discovered that some exceptions that were essentially the same were actually called as different exceptions. (For example, treating a type error as an InvalidArgumentException in one place but a RuntimeException in another place.) I also did not touch these, as I didn't want to touch any actual workflow with these changes.

There were also a number of instances where exception messages could benefit from a global function that outputs either the class of an object or the type of a primitive. The code that would power this function is actually already in `src/HashArray.php`.