diff --git a/src/Composer/Command/ValidateCommand.php b/src/Composer/Command/ValidateCommand.php
index e2a69abd5..430351b40 100644
--- a/src/Composer/Command/ValidateCommand.php
+++ b/src/Composer/Command/ValidateCommand.php
@@ -91,7 +91,6 @@ EOT
}
}
} catch (\Exception $e) {
- $output->writeln('' . $file . ' contains a JSON Syntax Error:');
$output->writeln('' . $e->getMessage() . '');
return 1;
diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php
index dc2538132..2e0581d27 100755
--- a/src/Composer/Json/JsonFile.php
+++ b/src/Composer/Json/JsonFile.php
@@ -15,6 +15,7 @@ namespace Composer\Json;
use Composer\Composer;
use JsonSchema\Validator;
use Seld\JsonLint\JsonParser;
+use Seld\JsonLint\ParsingException;
use Composer\Util\RemoteFilesystem;
use Composer\Downloader\TransportException;
@@ -148,7 +149,7 @@ class JsonFile
foreach ((array) $validator->getErrors() as $error) {
$errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
}
- throw new JsonValidationException('JSON file doesnt match expected schema "'.$this->path.'"', $errors);
+ throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
}
return true;
@@ -294,12 +295,12 @@ class JsonFile
$result = $parser->lint($json);
if (null === $result) {
if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
- throw new \UnexpectedValueException('JSON file is not UTF-8 encoded "'.$file.'"');
+ throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
}
return true;
}
- throw new JsonValidationException('JSON file is not valid "'.$file.'"'."\n".$result->getMessage(), $result->getDetails());
+ throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
}
}
diff --git a/tests/Composer/Test/Json/JsonFileTest.php b/tests/Composer/Test/Json/JsonFileTest.php
index 55bf603ea..491c8ea5e 100644
--- a/tests/Composer/Test/Json/JsonFileTest.php
+++ b/tests/Composer/Test/Json/JsonFileTest.php
@@ -198,9 +198,8 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase
try {
JsonFile::parseJson($json);
$this->fail();
- } catch (JsonValidationException $e) {
+ } catch (ParsingException $e) {
$this->assertContains($text, $e->getMessage());
- $this->assertNotEmpty($e->getErrors());
}
}