diff --git a/src/Utilities.php b/src/Utilities.php index b8b0c4f9..8b192583 100644 --- a/src/Utilities.php +++ b/src/Utilities.php @@ -106,23 +106,28 @@ public static function serializeForRollbar( } foreach ($obj as $key => $val) { - if (is_object($val)) { - $val = self::serializeObject( - $val, - $customKeys, - $objectHashes, - $maxDepth, - $depth - ); - } elseif (is_array($val)) { - $val = self::serializeForRollbar( - $val, - $customKeys, - $objectHashes, - $maxDepth, - $depth+1 - ); + try { + if (is_object($val)) { + $val = self::serializeObject( + $val, + $customKeys, + $objectHashes, + $maxDepth, + $depth + ); + } elseif (is_array($val)) { + $val = self::serializeForRollbar( + $val, + $customKeys, + $objectHashes, + $maxDepth, + $depth+1 + ); + } + } catch (\Throwable $e) { + $val = 'Error during serialization: '.$e->getMessage(); } + if ($customKeys !== null && in_array($key, $customKeys)) { $returnVal[$key] = $val;