Make sure schema issues are always reported correctly, but not in init when Composer is not required, fixes #9986
parent
6f992a6ea3
commit
e87a150f41
|
@ -420,9 +420,9 @@ class Application extends BaseApplication
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} catch (JsonValidationException $e) {
|
} catch (JsonValidationException $e) {
|
||||||
$errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
|
if ($required) {
|
||||||
$message = $e->getMessage() . ':' . PHP_EOL . $errors;
|
throw $e;
|
||||||
throw new JsonValidationException($message);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ use Composer\EventDispatcher\EventDispatcher;
|
||||||
use Composer\Autoload\AutoloadGenerator;
|
use Composer\Autoload\AutoloadGenerator;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
use Composer\Downloader\TransportException;
|
use Composer\Downloader\TransportException;
|
||||||
|
use Composer\Json\JsonValidationException;
|
||||||
use Seld\JsonLint\JsonParser;
|
use Seld\JsonLint\JsonParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -308,7 +309,13 @@ class Factory
|
||||||
throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
|
throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$file->validateSchema(JsonFile::LAX_SCHEMA);
|
$file->validateSchema(JsonFile::LAX_SCHEMA);
|
||||||
|
} catch (JsonValidationException $e) {
|
||||||
|
$errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
|
||||||
|
$message = $e->getMessage() . ':' . PHP_EOL . $errors;
|
||||||
|
throw new JsonValidationException($message);
|
||||||
|
}
|
||||||
$jsonParser = new JsonParser;
|
$jsonParser = new JsonParser;
|
||||||
try {
|
try {
|
||||||
$jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
|
$jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
|
||||||
|
|
Loading…
Reference in New Issue