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

Widen the Exception type to Throwable #2495

Merged
merged 2 commits into from
Dec 28, 2019

Conversation

gmponos
Copy link
Member

@gmponos gmponos commented Dec 23, 2019

I should have these changes included on this: #2493 but I thought about later.

Please review thoroughly the code.. there might be more places that need a change.

Thank you

@gmponos gmponos added this to the 7.0.0 milestone Dec 23, 2019
@GrahamCampbell
Copy link
Member

Not necessarily. It might not make sense to catch throwables, actually. Throwables that are not exceptions are errors in the code, and probably should totally crash everything, on purpose.

@gmponos
Copy link
Member Author

gmponos commented Dec 23, 2019

It might not make sense to catch throwables, actually

Yes for some of the cases of the current PR I have second thoughts also.. can you be more specific.. because I don't think that this applies everywhere..

For instance on my current PR I believe that MockHandler should accept Throwables.

@sagikazarmark
Copy link
Member

@GrahamCampbell 's comment refers to catching \Throwables, not accepting them and I kinda agree, although in some cases those caught throwables are actually wrapped in another exception and thrown again.

@gmponos
Copy link
Member Author

gmponos commented Dec 24, 2019

comment refers to catching \Throwables

Yes.. I had second thoughts too. So shall I revert every } catch (Throwable) { I did?

@sagikazarmark
Copy link
Member

No, I don't think you should.

For example: it's probably a good thing, that promises can now catch errors too, and return them as rejection.

But I'm not sure catching errors and returning them as RequestException is a good idea.

@gmponos
Copy link
Member Author

gmponos commented Dec 24, 2019

OK.. then can we have specific comments per case? :)

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

I very much agree with @GrahamCampbell. Catching exceptions and catching throwables are NOT the same thing.

Looking at the PR, all the changes makes sense. Like MessageFormatter or how we catch exceptions int $options['on_headers']($response).

Copy link
Member

@sagikazarmark sagikazarmark left a comment

Choose a reason for hiding this comment

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

tl;dr I would revert catching Throwables for now, but it should be accepted as an argument everywhere. We can revisit this decision later.

src/Client.php Outdated Show resolved Hide resolved
src/Handler/CurlFactory.php Outdated Show resolved Hide resolved
src/Handler/MockHandler.php Outdated Show resolved Hide resolved
src/Handler/StreamHandler.php Outdated Show resolved Hide resolved
@Nyholm Nyholm merged commit cce7ba5 into guzzle:master Dec 28, 2019
@Nyholm Nyholm mentioned this pull request Dec 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants