Skip to content

Commit

Permalink
[DX] Show the ParseException message in YAML file loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyweb committed Apr 20, 2020
1 parent 62565a1 commit d57b602
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Loader/YamlFileLoader.php
Expand Up @@ -66,7 +66,7 @@ public function load($file, $type = null)
try {
$parsedConfig = $this->yamlParser->parseFile($path);
} catch (ParseException $e) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: '.$e->getMessage(), $path), 0, $e);
} finally {
restore_error_handler();
}
Expand Down
Expand Up @@ -47,7 +47,7 @@ protected function loadResource($resource)
try {
$messages = $this->yamlParser->parseFile($resource);
} catch (ParseException $e) {
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s".', $resource), 0, $e);
throw new InvalidResourceException(sprintf('The file "%s" does not contain valid YAML: '.$e->getMessage(), $resource), 0, $e);
} finally {
restore_error_handler();
}
Expand Down
Expand Up @@ -124,7 +124,7 @@ private function parseFile($path)
try {
$classes = $this->yamlParser->parseFile($path, Yaml::PARSE_CONSTANT);
} catch (ParseException $e) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $path), 0, $e);
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: '.$e->getMessage(), $path), 0, $e);
} finally {
restore_error_handler();
}
Expand Down

0 comments on commit d57b602

Please sign in to comment.