1
0
Fork 0

Improved error messages in ArrayLoader

Added package name to exception message when an error occurred in source or dist keys
pull/1666/head
deguif 2013-03-06 18:08:55 +01:00
parent b474944155
commit 834f0b49e5
1 changed files with 5 additions and 3 deletions

View File

@ -74,7 +74,8 @@ class ArrayLoader implements LoaderInterface
if (isset($config['source'])) { if (isset($config['source'])) {
if (!isset($config['source']['type']) || !isset($config['source']['url'])) { if (!isset($config['source']['type']) || !isset($config['source']['url'])) {
throw new \UnexpectedValueException(sprintf( throw new \UnexpectedValueException(sprintf(
"package source should be specified as {\"type\": ..., \"url\": ...},\n%s given", "Package %s's source key should be specified as {\"type\": ..., \"url\": ...},\n%s given.",
$config['name'],
json_encode($config['source']) json_encode($config['source'])
)); ));
} }
@ -87,8 +88,9 @@ class ArrayLoader implements LoaderInterface
if (!isset($config['dist']['type']) if (!isset($config['dist']['type'])
|| !isset($config['dist']['url'])) { || !isset($config['dist']['url'])) {
throw new \UnexpectedValueException(sprintf( throw new \UnexpectedValueException(sprintf(
"package dist should be specified as ". "Package %s's dist key should be specified as ".
"{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given", "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
$config['name'],
json_encode($config['dist']) json_encode($config['dist'])
)); ));
} }