Add backtrace to errors in json

pull/3792/head
Isaac Connor 2023-09-25 16:32:20 -04:00
parent 1fdf7f2b31
commit 45bcb13045
1 changed files with 10 additions and 0 deletions

View File

@ -1741,18 +1741,28 @@ function checkJsonError($value) {
switch ( json_last_error() ) {
case JSON_ERROR_DEPTH :
ZM\Error("Unable to decode JSON string '$value', maximum stack depth exceeded");
$backTrace = debug_backtrace();
ZM\Debug($message.' from '.print_r($backTrace, true));
break;
case JSON_ERROR_CTRL_CHAR :
ZM\Error("Unable to decode JSON string '$value', unexpected control character found");
$backTrace = debug_backtrace();
ZM\Debug($message.' from '.print_r($backTrace, true));
break;
case JSON_ERROR_STATE_MISMATCH :
ZM\Error("Unable to decode JSON string '$value', invalid or malformed JSON");
$backTrace = debug_backtrace();
ZM\Debug($message.' from '.print_r($backTrace, true));
break;
case JSON_ERROR_SYNTAX :
ZM\Error("Unable to decode JSON string '$value', syntax error");
$backTrace = debug_backtrace();
ZM\Debug($message.' from '.print_r($backTrace, true));
break;
default :
ZM\Error("Unable to decode JSON string '$value', unexpected error ".json_last_error());
$backTrace = debug_backtrace();
ZM\Debug($message.' from '.print_r($backTrace, true));
break;
case JSON_ERROR_NONE:
break;