Skip to content

Allow UniqueConstraintViolationException on EntityManager::flush() #295

@gbirke

Description

@gbirke

The following code will produce an error:

try {
   $entityManager->flush();
} catch( UniqueConstraintViolationException $ex ) {
   // do something with $ex here
}

The error message is Doctrine\DBAL\Exception\UniqueConstraintViolationException is never thrown in the try block. This is kind-of-true, since that exception is not declared on EntityManager::flush, but bubbles up from the DBAL implementation. It's been raised as an issue on the repo ( doctrine/orm#7780 ), but so far it looks like this is "by design" and won't be fixed.

Could you create an "exception" (no pun intended) for this exception in PHPStan to ignore catch segments that look for UniqueConstraintViolationException?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions