1
0
Fork 0

Fix exception when a json file can not be downloaded

pull/534/head
Jordi Boggiano 2012-04-06 20:05:59 +02:00
parent a67f62990c
commit b14366ed08
1 changed files with 4 additions and 1 deletions

View File

@ -18,6 +18,7 @@ use JsonSchema\Validator;
use Seld\JsonLint\JsonParser; use Seld\JsonLint\JsonParser;
use Composer\Util\StreamContextFactory; use Composer\Util\StreamContextFactory;
use Composer\Util\RemoteFilesystem; use Composer\Util\RemoteFilesystem;
use Composer\Downloader\TransportException;
/** /**
* Reads/writes json files. * Reads/writes json files.
@ -81,8 +82,10 @@ class JsonFile
} else { } else {
$json = file_get_contents($this->path); $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) { } 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); return static::parseJson($json);