minor #29928 [DependencyInjection] forward the parse error to the calling code (xabbuh)
This PR was merged into the 3.4 branch.
Discussion
----------
[DependencyInjection] forward the parse error to the calling code
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #29891
| License | MIT
| Doc PR |
This change does not fully solve the linked issue, but improves the exception a bit by providing a bit more context.
The error page will no start like this:
![bildschirmfoto 2019-01-18 um 12 28 14](https://user-images.githubusercontent.com/1957048/51384558-f7af3600-1b1c-11e9-9744-a40c41c821ce.png)
Commits
-------
c5c2d31fef
forward the parse error to the calling code
This commit is contained in:
commit
333b544d8b
@ -383,7 +383,7 @@ class XmlFileLoader extends FileLoader
|
|||||||
try {
|
try {
|
||||||
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
|
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
|
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": %s', $file, $e->getMessage()), $e->getCode(), $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->validateExtensions($dom, $file);
|
$this->validateExtensions($dom, $file);
|
||||||
|
@ -666,7 +666,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
try {
|
try {
|
||||||
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
|
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
|
||||||
} catch (ParseException $e) {
|
} catch (ParseException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
|
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s', $file, $e->getMessage()), 0, $e);
|
||||||
} finally {
|
} finally {
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user