From b14366ed08366e4c0472514aa1771d42d7201b1f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 6 Apr 2012 20:05:59 +0200 Subject: [PATCH] Fix exception when a json file can not be downloaded --- src/Composer/Json/JsonFile.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 5c891814e..63c21bda3 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -18,6 +18,7 @@ use JsonSchema\Validator; use Seld\JsonLint\JsonParser; use Composer\Util\StreamContextFactory; use Composer\Util\RemoteFilesystem; +use Composer\Downloader\TransportException; /** * Reads/writes json files. @@ -81,8 +82,10 @@ class JsonFile } else { $json = file_get_contents($this->path); } + } catch (TransportException $e) { + throw new \RuntimeException('Could not read '.$this->path.', either you or the remote host is probably offline'."\n\n".$e->getMessage()); } catch (\Exception $e) { - throw new \RuntimeException('Could not read '.$this->path.', you are probably offline ('.$e->getMessage().')'); + throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage()); } return static::parseJson($json);