From 32a7ceac2f78359b3ce26ab7e734ab71ff41a4e4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 13 Jul 2022 10:06:00 +0200 Subject: [PATCH] Improve exception message when a package cannot be added in another repo, refs #10940 --- src/Composer/Package/BasePackage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index a3ec9c570..8f225cbd3 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -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; }