json decoding errors shouldnt' be fatal

This commit is contained in:
Isaac Connor 2020-07-29 16:40:31 -04:00
parent d658479048
commit 4c5a88a822
1 changed files with 12 additions and 7 deletions

View File

@ -2100,15 +2100,20 @@ function checkJsonError($value) {
$value = var_export($value, true);
switch ( json_last_error() ) {
case JSON_ERROR_DEPTH :
ZM\Fatal("Unable to decode JSON string '$value', maximum stack depth exceeded");
ZM\Error("Unable to decode JSON string '$value', maximum stack depth exceeded");
break;
case JSON_ERROR_CTRL_CHAR :
ZM\Fatal("Unable to decode JSON string '$value', unexpected control character found");
ZM\Error("Unable to decode JSON string '$value', unexpected control character found");
break;
case JSON_ERROR_STATE_MISMATCH :
ZM\Fatal("Unable to decode JSON string '$value', invalid or malformed JSON");
ZM\Error("Unable to decode JSON string '$value', invalid or malformed JSON");
break;
case JSON_ERROR_SYNTAX :
ZM\Fatal("Unable to decode JSON string '$value', syntax error");
ZM\Error("Unable to decode JSON string '$value', syntax error");
break;
default :
ZM\Fatal("Unable to decode JSON string '$value', unexpected error ".json_last_error());
ZM\Error("Unable to decode JSON string '$value', unexpected error ".json_last_error());
break;
case JSON_ERROR_NONE:
break;
}