Skip to content

Commit

Permalink
minor #23896 [Inlt] Fix JsonBundleReader exceptions (ksjogo)
Browse files Browse the repository at this point in the history
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #23896).

Discussion
----------

[Inlt] Fix JsonBundleReader exceptions

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

Commits
-------

22a6642 Update JsonBundleReader.php
  • Loading branch information
nicolas-grekas committed Aug 15, 2017
2 parents 0b613db + 22a6642 commit f1c65c0
Showing 1 changed file with 6 additions and 9 deletions.
Expand Up @@ -32,27 +32,24 @@ public function read($path, $locale)

if (!file_exists($fileName)) {
throw new ResourceBundleNotFoundException(sprintf(
'The resource bundle "%s/%s.json" does not exist.',
$path,
$locale
'The resource bundle "%s" does not exist.',
$fileName
));
}

if (!is_file($fileName)) {
throw new RuntimeException(sprintf(
'The resource bundle "%s/%s.json" is not a file.',
$path,
$locale
'The resource bundle "%s" is not a file.',
$fileName
));
}

$data = json_decode(file_get_contents($fileName), true);

if (null === $data) {
throw new RuntimeException(sprintf(
'The resource bundle "%s/%s.json" contains invalid JSON: %s',
$path,
$locale,
'The resource bundle "%s" contains invalid JSON: %s',
$fileName,
self::getLastJsonError()
));
}
Expand Down

0 comments on commit f1c65c0

Please sign in to comment.