Skip to content

Commit

Permalink
Merge pull request #576 from gap-referencement/stephpy-patch-1
Browse files Browse the repository at this point in the history
Catch error during serialization
  • Loading branch information
danielmorell authored Oct 31, 2022
2 parents d6ec7a3 + 0223e4b commit 169cee9
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 169cee9

Please sign in to comment.