1
0
Fork 0

Clarify exception messages when a package can not be loaded from a composer repository, fixes #1070

pull/1040/merge
Jordi Boggiano 2012-09-08 02:00:02 +02:00
parent 056dc5d690
commit fe4516aff8
1 changed files with 12 additions and 3 deletions

View File

@ -135,7 +135,7 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
}
foreach ($this->rawData as $package) {
if (false === call_user_func($callback, $package = $this->loader->load($package, $class))) {
if (false === call_user_func($callback, $package = $this->createPackage($package, $class))) {
return false;
}
if ($package->getAlias()) {
@ -153,7 +153,7 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
*/
public function loadPackage(array $data)
{
$package = $this->loader->load($data['raw'], 'Composer\Package\Package');
$package = $this->createPackage($data['raw'], 'Composer\Package\Package');
$package->setRepository($this);
return $package;
@ -180,7 +180,7 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
$repoData = $this->loadDataFromServer();
foreach ($repoData as $package) {
$this->addPackage($this->loader->load($package, 'Composer\Package\CompletePackage'));
$this->addPackage($this->createPackage($package, 'Composer\Package\CompletePackage'));
}
}
@ -262,4 +262,13 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository
return $packages;
}
protected function createPackage(array $data, $class)
{
try {
return $this->loader->load($data, 'Composer\Package\CompletePackage');
} catch (\Exception $e) {
throw new \RuntimeException('Could not load package '.$data['name'].' in '.$this->url.': ['.get_class($e).'] '.$e->getMessage());
}
}
}