Skip to content

[HttpClient] exceptions carry response #30567

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

Merged

Conversation

antonch1989
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #30502
License MIT
Doc PR

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Thanks for starting this.
I think we should add the method in an interface in contracts.
If we add it to the base ExceptionInterface, it should be nullable, because the response object might not be instantiated yet when this is thrown.
We could alternatively add a new base HttpExceptionInterface that would add this method to Server/Client/RedirectionExceptionInterface - that's mean the method is not on TransportExceptionInterface.
Any preference?

@@ -20,8 +20,12 @@
*/
trait HttpExceptionTrait
{
/** @var ResponseInterface */
Copy link
Member

Choose a reason for hiding this comment

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

should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the solution with a new interface looks cleaner, I'll do this way if there are no objections


use Symfony\Contracts\HttpClient\ResponseInterface;

interface HttpExceptionInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of HttpResponseExceptionInterface? The current name doesn't imply it has anything to do with a response, while the getter implies there's always a response

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my opinion the current naming is fine, let's wait for some other comments

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the name HttpExceptionInterface personnaly, but the interface should extend ExceptionInterface


use Symfony\Contracts\HttpClient\ResponseInterface;

interface HttpExceptionInterface
Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the name HttpExceptionInterface personnaly, but the interface should extend ExceptionInterface

@@ -18,6 +18,6 @@
*
* @experimental in 1.1
*/
interface RedirectionExceptionInterface extends ExceptionInterface
interface RedirectionExceptionInterface extends ExceptionInterface, HttpExceptionInterface
Copy link
Member

Choose a reason for hiding this comment

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

interface RedirectionExceptionInterface extends HttpExceptionInterface
please do the same ClientExceptionInterface and ServerExceptionInterface

@@ -18,6 +18,6 @@
*
* @experimental in 1.1
*/
interface ClientExceptionInterface extends ExceptionInterface
interface ClientExceptionInterface extends ExceptionInterface, HttpExceptionInterface
Copy link
Member

Choose a reason for hiding this comment

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

ExceptionInterface should be removed as it's now embeded in HttpExceptionInterface
same in the 2 other exception interfaces

use Symfony\Contracts\HttpClient\ResponseInterface;

/**
* Interface for getting response from an exception
Copy link
Member

Choose a reason for hiding this comment

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

Base interface for HTTP-related exceptions.

@fabpot
Copy link
Member

fabpot commented Mar 19, 2019

Thank you @antonch1989.

@fabpot fabpot force-pushed the issue-30502-exceptions-carry-respons branch from bf99300 to 103448c Compare March 19, 2019 07:50
@fabpot fabpot merged commit 103448c into symfony:master Mar 19, 2019
fabpot added a commit that referenced this pull request Mar 19, 2019
This PR was squashed before being merged into the 4.3-dev branch (closes #30567).

Discussion
----------

[HttpClient] exceptions carry response

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | #30502
| License       | MIT
| Doc PR        |

Commits
-------

103448c [HttpClient] exceptions carry response
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
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.

6 participants