diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/appframework/http/jsonresponse.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/public/appframework/http/jsonresponse.php b/lib/public/appframework/http/jsonresponse.php index 1a770109d45..456a5616d4d 100644 --- a/lib/public/appframework/http/jsonresponse.php +++ b/lib/public/appframework/http/jsonresponse.php @@ -61,9 +61,16 @@ class JSONResponse extends Response { * Returns the rendered json * @return string the rendered json * @since 6.0.0 + * @throws \Exception If data could not get encoded */ - public function render(){ - return json_encode($this->data); + public function render() { + $response = json_encode($this->data); + if($response === false) { + throw new \Exception(sprintf('Could not json_encode due to invalid ' . + 'non UTF-8 characters in the array: %s', var_export($this->data, true))); + } + + return $response; } /** |