Catch exceptions to restore the error handler

This commit is contained in:
Jerome TAMARELLE 2014-07-18 16:10:40 +02:00 committed by Fabien Potencier
parent ddf95c7adc
commit d952f9049e

View File

@ -106,9 +106,15 @@ class JsonResponse extends Response
}
});
$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());