minor #10945 [Component][Translation][Loader] Include file path in exception message (skafandri)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #10945).

Discussion
----------

[Component][Translation][Loader] Include file path in exception message

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | on
| Fixed tickets |
| License       | MIT
| Doc PR        |

When Translation component tryes to load an invalid YAML file, you get

    InvalidResourceException: Error parsing YAML.
Which is not very helpful, I spent 1 hour looking for the invalid file, I think is better to include the file path in the exception message.

Commits
-------

3d576ef Include file path in exception
This commit is contained in:
Fabien Potencier 2014-05-21 18:08:06 +02:00
commit 95f196ff2d
1 changed files with 1 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class YamlFileLoader extends ArrayLoader implements LoaderInterface
try {
$messages = $this->yamlParser->parse(file_get_contents($resource));
} catch (ParseException $e) {
throw new InvalidResourceException('Error parsing YAML.', 0, $e);
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e);
}
// empty file