Skip to content

Commit

Permalink
Catch error during serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
stephpy authored Aug 3, 2022
1 parent d6ec7a3 commit 0223e4b
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0223e4b

Please sign in to comment.