8000 minor #29928 [DependencyInjection] forward the parse error to the cal… · symfony/symfony@333b544 · GitHub
[go: up one dir, main page]

Skip to content

Commit 333b544

Browse files
committed
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 ------- c5c2d31 forward the parse error to the calling code
2 parents b972d15 + c5c2d31 commit 333b544

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private function parseFileToDOM($file)
383383
try {
384384
$dom = XmlUtils::loadFile($file, [$this, 'validateSchema']);
385385
} catch (\InvalidArgumentException $e) {
386-
throw new InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
386+
throw new InvalidArgumentException(sprintf('Unable to parse file "%s": %s', $file, $e->getMessage()), $e->getCode(), $e);
387387
}
388388

389389
$this->validateExtensions($dom, $file);

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ protected function loadFile($file)
666666
try {
667667
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
668668
} catch (ParseException $e) {
669-
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
669+
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s', $file, $e->getMessage()), 0, $e);
670670
} finally {
671671
restore_error_handler();
672672
}

0 commit comments

Comments
 (0)
0