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

Add invalid argument exception #2163

Merged
merged 3 commits into from Dec 21, 2018

Conversation

gmponos
Copy link
Member

@gmponos gmponos commented Oct 6, 2018

Hello there,

Let's say I have the following class:

class MyClientWrapper {
    private $httpClient;

    public function callSomething(){
          $response = $this->httpClient->get('/');
          return GuzzleHttp\json_decode($response->getBody());
    }
}

when I call the function above I have to do something like this:

try{
   $mywrapper->callSomething();
} catch (\InvalidArgumentException | GuzzleException $e){
    ....
}

This has the defect that I if another part of my code throws an InvalidArgumentException inside this class I can not separate it from the the GuzzleHttp InvalidArgumentException.

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.

I had one minor comment, apart from that 👍


namespace GuzzleHttp\Exception;

class InvalidArgumentException extends \InvalidArgumentException implements GuzzleException {}
Copy link
Member

Choose a reason for hiding this comment

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

I think this class should be final for now, we can always open it up later.

Also, please add a trailing new line to the end of the file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.. I added the new line but I am not sure if it is visible through the PR changes tab

@FrontEndCoffee
Copy link
Contributor

Looks good 👍

@gmponos gmponos mentioned this pull request Nov 4, 2018
Copy link
Contributor

@localheinz localheinz left a comment

Choose a reason for hiding this comment

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

👍

@sagikazarmark
Copy link
Member

Looks good as always @gmponos ! Thanks!

@sagikazarmark sagikazarmark merged commit d9b22f4 into guzzle:master Dec 21, 2018
@gmponos gmponos deleted the add_invalid_argument_exception branch December 21, 2018 16:36
@wirwolf
Copy link

wirwolf commented Oct 18, 2019

Hello @gmponos, i create a fork of this repo and release this marge request into the new version(6.4.0).

Namespace compatibility is 100%, and you can use my changes if you patch composer.json in your projects

  • replace "guzzlehttp/guzzle": "^6.3" to "someblackmagic/guzzle": "^6.4"
  • add "guzzlehttp/guzzle": "6.3.*" into replace block

Fork link: https://github.com/SomeBlackMagic/guzzle/

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

5 participants