Skip to content

Commit fc6cf3d

Browse files
committed
[DX] Show the ParseException message in YAML file loaders
1 parent 08ded7f commit fc6cf3d

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function load($file, $type = null)
6666
try {
6767
$parsedConfig = $this->yamlParser->parseFile($path);
6868
} catch (ParseException $e) {
69-
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
69+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $path).': '.$e->getMessage(), 0, $e);
7070
} finally {
7171
restore_error_handler();
7272
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function loadResource($resource)
4747
try {
4848
$messages = $this->yamlParser->parseFile($resource);
4949
} catch (ParseException $e) {
50-
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s".', $resource), 0, $e);
50+
throw new InvalidResourceException(sprintf('The file "%s" does not contain valid YAML', $resource).': '.$e->getMessage(), 0, $e);
5151
} finally {
5252
restore_error_handler();
5353
}

src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private function parseFile($path)
124124
try {
125125
$classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
126126
} catch (ParseException $e) {
127-
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
127+
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $path).': '.$e->getMessage(), 0, $e);
128128
} finally {
129129
restore_error_handler();
130130
}

0 commit comments

Comments
 (0)