Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch Throwable instead of just catching Exception #5796

Closed
wants to merge 1 commit into from

Conversation

BenMorel
Copy link
Contributor

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.

@fprochazka
Copy link
Contributor

fprochazka commented May 9, 2016

Is something blocking this, or you guys just haven't had time to look at this? Also, the same problem is in dbal (I've created a PR for it doctrine/dbal#2390 )

@Ocramius
Copy link
Member

Ocramius commented May 9, 2016

@fprochazka we're simply stuck outside the githubs.

@@ -749,7 +751,9 @@ public function dropSchema(array $classes)
foreach ($dropSchemaSql as $sql) {
try {
$conn->executeQuery($sql);
} catch (\Exception $e) {
} catch (\Throwable $e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that i think about it, this one probably shouldn't caught.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Godd catch. Indeed, this should halt execution

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another issue then :)

@rreynier
Copy link

rreynier commented Sep 1, 2017

What's the deal with this one? Shouldn't this get merged?

@Ocramius
Copy link
Member

Ocramius commented Sep 1, 2017

@rreynier see comments above?

@rreynier
Copy link

rreynier commented Sep 1, 2017

@Ocramius what do you mean by being stuck outside of GitHub?

@Ocramius
Copy link
Member

Ocramius commented Sep 1, 2017 via email

@Ocramius Ocramius added this to the 2.6.0 milestone Sep 2, 2017
@Ocramius Ocramius self-assigned this Sep 2, 2017
Ocramius added a commit that referenced this pull request Sep 2, 2017
Ocramius added a commit that referenced this pull request Sep 2, 2017
@Ocramius Ocramius closed this in 4bc29d1 Sep 2, 2017
@Ocramius
Copy link
Member

Ocramius commented Sep 2, 2017

Manually rebased and merged to master via 4bc29d1

Thanks @BenMorel!

@Ocramius Ocramius changed the title Catch Throwable in PHP 7 Catch Throwable instead of just catching Exception Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants