1
0
Fork 0

Improve exception message when a package cannot be added in another repo, refs #10940

pull/10985/head
Jordi Boggiano 2022-07-13 10:06:00 +02:00
parent 75ef4903ef
commit 32a7ceac2f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 6 additions and 1 deletions

View File

@ -135,7 +135,12 @@ abstract class BasePackage implements PackageInterface
public function setRepository(RepositoryInterface $repository)
{
if ($this->repository && $repository !== $this->repository) {
throw new \LogicException('A package can only be added to one repository');
throw new \LogicException(sprintf(
'Package "%s" cannot be added to repository "%s" as it is already in repository "%s".',
$this->getPrettyName(),
$repository->getRepoName(),
$this->repository->getRepoName(),
));
}
$this->repository = $repository;
}