diff --git a/src/DoctrineBatchUtils/BatchProcessing/Exception/MissingBatchItemException.php b/src/DoctrineBatchUtils/BatchProcessing/Exception/MissingBatchItemException.php index b326ad9..52d179d 100644 --- a/src/DoctrineBatchUtils/BatchProcessing/Exception/MissingBatchItemException.php +++ b/src/DoctrineBatchUtils/BatchProcessing/Exception/MissingBatchItemException.php @@ -19,12 +19,17 @@ class MissingBatchItemException extends UnexpectedValueException implements Exce { public static function fromInvalidReference(ClassMetadata $metadata, object $object): MissingBatchItemException { + $identifier = json_encode($metadata->getIdentifierValues($object)); + if ($identifier === false) { + $identifier = 'unknown'; + } + return new self(sprintf( 'Requested batch item %s#%s (of type %s) with identifier "%s" could not be found', get_class($object), spl_object_hash($object), $metadata->getName(), - json_encode($metadata->getIdentifierValues($object)), + $identifier, )); } }