Skip to content

Commit f942dfc

Browse files
catalinuxthilanga
authored andcommitted
Check encode of your data (dingo#1380)
* Check encode of your data * formatting * formatting back * space after if * empty line befere return - formatting * space before curly bracket - formatting
1 parent 438f291 commit f942dfc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Http/Response/Format/Json.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ protected function morphToArray($value)
9797
*/
9898
protected function encode($content)
9999
{
100-
return json_encode($content);
100+
$encodedString = json_encode($content);
101+
if ($encodedString === false) {
102+
throw new \ErrorException('Error encoding data in JSON format: '.json_last_error());
103+
}
104+
105+
return $encodedString;
101106
}
102107
}

0 commit comments

Comments
 (0)