Skip to content

Commit b9fd914

Browse files
committed
Add $previous to DocumentNotFoundException
1 parent 054cebb commit b9fd914

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Doctrine/ODM/MongoDB/DocumentNotFoundException.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Doctrine\ODM\MongoDB;
66

7+
use JsonException;
8+
79
use function json_encode;
810
use function sprintf;
911

@@ -20,10 +22,15 @@ final class DocumentNotFoundException extends MongoDBException
2022
*/
2123
public static function documentNotFound(string $className, $identifier): self
2224
{
25+
try {
26+
$id = json_encode($identifier, JSON_THROW_ON_ERROR);
27+
} catch (JsonException $e) {
28+
}
29+
2330
return new self(sprintf(
2431
'The "%s" document with identifier %s could not be found.',
2532
$className,
26-
json_encode($identifier, JSON_THROW_ON_ERROR)
27-
));
33+
$id ?? false,
34+
), 0, $e ?? null);
2835
}
2936
}

0 commit comments

Comments
 (0)