doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.86k stars 2.5k forks source link

Catch Rollback Driver Exception #11482

Closed rodnaph closed 3 weeks ago

rodnaph commented 3 weeks ago

Adds a try/catch when rolling back after an exception during UnitOfWork commit, so exception is not lost.

Currently the connection driver could throw an exception on rollback (eg. if the exception causes there to be no active transaction) which results in the driver exception propagating to the caller, and the commit Throwable being lost. Instead here, the rollback exception is swallowed so the original commit exception can be thrown to the caller.

I'm not sure what the best behaviour is here, so please advise. I've also not added any tests yet as it looked like I'd need to do some wrangling on the mocks being used, so wanted to at least check this was a reasonable idea before spending time on it.

greg0ire commented 3 weeks ago

Can you please first read https://github.com/doctrine/orm/issues/7545 ?

rodnaph commented 3 weeks ago

👍