8000 [JsonResponse] Silent only JSON errors by GromNaN · Pull Request #11418 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[JsonResponse] Silent only JSON errors #11418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Catch exceptions to restore the error handler
  • Loading branch information
GromNaN committed Sep 15, 2014
commit 6e8c7fc64bcd1d56a03c5adc8f8ad6077dda33aa
10 changes: 8 additions & 2 deletions src/Symfony/Component/HttpFoundation/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ public function setData($data = array())
}
});

$this->data = json_encode($data, $this->encodingOptions);
try {
$this->data = json_encode($data, $this->encodingOptions);

restore_error_handler();
restore_error_handler();
} catch (\Exception $exception) {
restore_error_handler();

throw $exception;
}

if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException($this->transformJsonError());
Expand Down
0