Catching error when compacting doesn't work
authorMichael <heluecht@pirati.ca>
Sat, 13 Oct 2018 13:17:10 +0000 (13:17 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 13 Oct 2018 13:17:10 +0000 (13:17 +0000)
src/Util/JsonLD.php

index cf23276..5380c3c 100644 (file)
@@ -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);
        }