VcsRepository: make transport exceptions during initialize run accessible
* also display the http status code in composer failed to load a composer.json filepull/8484/head
parent
082422f334
commit
dd2cc3e985
|
@ -45,6 +45,7 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
||||||
/** @var VersionCacheInterface */
|
/** @var VersionCacheInterface */
|
||||||
private $versionCache;
|
private $versionCache;
|
||||||
private $emptyReferences = array();
|
private $emptyReferences = array();
|
||||||
|
private $versionTransportExceptions = array();
|
||||||
|
|
||||||
public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $dispatcher = null, array $drivers = null, VersionCacheInterface $versionCache = null)
|
public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $dispatcher = null, array $drivers = null, VersionCacheInterface $versionCache = null)
|
||||||
{
|
{
|
||||||
|
@ -125,6 +126,11 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
||||||
return $this->emptyReferences;
|
return $this->emptyReferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getVersionTransportExceptions()
|
||||||
|
{
|
||||||
|
return $this->versionTransportExceptions;
|
||||||
|
}
|
||||||
|
|
||||||
protected function initialize()
|
protected function initialize()
|
||||||
{
|
{
|
||||||
parent::initialize();
|
parent::initialize();
|
||||||
|
@ -226,11 +232,14 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
||||||
|
|
||||||
$this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
|
$this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
if ($e instanceof TransportException && $e->getCode() === 404) {
|
if ($e instanceof TransportException) {
|
||||||
|
$this->versionTransportExceptions['tags'][$tag] = $e;
|
||||||
|
if ($e->getCode() === 404) {
|
||||||
$this->emptyReferences[] = $identifier;
|
$this->emptyReferences[] = $identifier;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ($isVeryVerbose) {
|
if ($isVeryVerbose) {
|
||||||
$this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()).'</warning>');
|
$this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -306,11 +315,12 @@ class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInt
|
||||||
}
|
}
|
||||||
$this->addPackage($package);
|
$this->addPackage($package);
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
|
$this->versionTransportExceptions['branches'][$branch] = $e;
|
||||||
if ($e->getCode() === 404) {
|
if ($e->getCode() === 404) {
|
||||||
$this->emptyReferences[] = $identifier;
|
$this->emptyReferences[] = $identifier;
|
||||||
}
|
}
|
||||||
if ($isVeryVerbose) {
|
if ($isVeryVerbose) {
|
||||||
$this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found</warning>');
|
$this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
Loading…
Reference in New Issue