Use ORMInvalidArgumentException::entityNotManaged($entity) in UnitOfWork::computeSingleEntityChangeSet() #5441

Closed
opened 2026-01-22 15:07:52 +01:00 by admin · 1 comment
Owner

Originally created by @Aerendir on GitHub (Mar 2, 2017).

At line 475 is thrown a generic \InvalidArgumentException().

As Doctrine provides a dedicated ORMInvalidArgumentException::entityNotManaged($entity) is better to use this so the exception can be caught.

Currently I need to catch the exception at that line, but only if it comes from Doctrine and I can't as the generic PHP exception is used.

Originally created by @Aerendir on GitHub (Mar 2, 2017). At [line 475](https://github.com/doctrine/doctrine2/blob/v2.5.6/lib/Doctrine/ORM/UnitOfWork.php#L475) is thrown a generic `\InvalidArgumentException()`. As Doctrine provides a dedicated `ORMInvalidArgumentException::entityNotManaged($entity)` is better to use this so the exception can be caught. Currently I need to catch the exception at that line, but only if it comes from Doctrine and I can't as the generic PHP exception is used.
admin added the Improvement label 2026-01-22 15:07:52 +01:00
admin closed this issue 2026-01-22 15:07:52 +01:00
Author
Owner

@Ocramius commented on GitHub (Mar 2, 2017):

@Aerendir dye ti BC concerns, it needs to still extend InvalidArgumentException though.

@Ocramius commented on GitHub (Mar 2, 2017): @Aerendir dye ti BC concerns, it needs to still extend `InvalidArgumentException` though.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5441