From fc6cf3d3c6903597ad4576e0123cd1f1a8155f59 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Mon, 20 Apr 2020 12:25:20 +0200 Subject: [PATCH] [DX] Show the ParseException message in YAML file loaders --- .../Component/DependencyInjection/Loader/YamlFileLoader.php | 2 +- src/Symfony/Component/Routing/Loader/YamlFileLoader.php | 2 +- src/Symfony/Component/Translation/Loader/YamlFileLoader.php | 2 +- .../Component/Validator/Mapping/Loader/YamlFileLoader.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index bc0c55e94d..ae970dbdf1 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -660,7 +660,7 @@ class YamlFileLoader extends FileLoader try { $configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS); } catch (ParseException $e) { - throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: '.$e->getMessage(), $file), 0, $e); + throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML', $file).': '.$e->getMessage(), 0, $e); } finally { restore_error_handler(); } diff --git a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php index 568827695b..57f1270d9f 100644 --- a/src/Symfony/Component/Routing/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/YamlFileLoader.php @@ -66,7 +66,7 @@ class YamlFileLoader extends FileLoader 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', $path).': '.$e->getMessage(), 0, $e); } finally { restore_error_handler(); } diff --git a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php index 41700df24b..0c25787dc7 100644 --- a/src/Symfony/Component/Translation/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/YamlFileLoader.php @@ -47,7 +47,7 @@ class YamlFileLoader extends FileLoader 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', $resource).': '.$e->getMessage(), 0, $e); } finally { restore_error_handler(); } diff --git a/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php index 0f6166674d..519c2ed36d 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/YamlFileLoader.php @@ -124,7 +124,7 @@ class YamlFileLoader extends FileLoader 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', $path).': '.$e->getMessage(), 0, $e); } finally { restore_error_handler(); }