[PR #5796] Catch Throwable instead of just catching Exception #9730

Open
opened 2026-01-22 16:05:14 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/5796

State: closed
Merged: No


Several code blocks have a catch-all catch (\Exception) { ... }. This is OK in PHP 5, but not sufficient in PHP 7, as the new base interface is Throwable, and catching Exception does not catch Error instances.

This PR catches Throwable by default, then catches Exception for PHP 5. The fact that Throwable is not defined in PHP 5 is not a problem in a catch block.

This leads to a bit of code duplication, but there's not much we can do to avoid this I'm afraid.

**Original Pull Request:** https://github.com/doctrine/orm/pull/5796 **State:** closed **Merged:** No --- Several code blocks have a catch-all `catch (\Exception) { ... }`. This is OK in PHP 5, but not sufficient in PHP 7, as the new base interface is `Throwable`, and catching `Exception` does not catch `Error` instances. This PR catches `Throwable` by default, then catches `Exception` for PHP 5. The fact that `Throwable` is not defined in PHP 5 is not a problem in a catch block. This leads to a bit of code duplication, but there's not much we can do to avoid this I'm afraid.
admin added the pull-request label 2026-01-22 16:05:14 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9730