Catching error when compacting doesn't work

2022.09-rc
Michael 2018-10-13 13:17:10 +00:00
rodzic af8a383be0
commit d23386f9b2
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -92,7 +92,14 @@ class JsonLD
$jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
$compacted = jsonld_compact($jsonobj, $context);
try {
$compacted = jsonld_compact($jsonobj, $context);
}
catch (Exception $e) {
$compacted = false;
logger('compacting error:' . print_r($e, true), LOGGER_DEBUG);
}
return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
}