Skip to content

Commit

Permalink
Merge pull request #10248 from burzum/better-exception-msg
Browse files Browse the repository at this point in the history
Improving an error message in Association.php
  • Loading branch information
lorenzo committed Feb 17, 2017
2 parents 0d2da99 + e91a091 commit e7515bc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ORM/Association.php
Expand Up @@ -414,11 +414,16 @@ public function getTarget()
$className = $this->_getClassName($registryAlias, ['className' => $this->_className]);

if (!$this->_targetTable instanceof $className) {
$targetClassName = get_class($this->_targetTable);
$errorMessage = '%s association "%s" of type "%s" to "%s" doesn\'t match the expected class "%s". ';
$errorMessage .= 'You can\'t have an association of the same name with a different target "className" option anywhere in your app.';

throw new RuntimeException(sprintf(
'Invalid Table retrieved from a registry. Requested: %s, got: %s',
$className,
$targetClassName
$errorMessage,
get_class($this->_sourceTable),
$this->getName(),
$this->type(),
get_class($this->_targetTable),
$className
));
}
}
Expand Down

0 comments on commit e7515bc

Please sign in to comment.