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

Fix exceptions classes #81

Merged
merged 2 commits into from
Jun 16, 2016
Merged

Fix exceptions classes #81

merged 2 commits into from
Jun 16, 2016

Conversation

Maks3w
Copy link

@Maks3w Maks3w commented Jan 17, 2016

Use InvalidArgumentException when $allowed_algs is not array

Exception thrown if an argument is not of the expected type.
http://php.net/manual/en/class.invalidargumentexception.php

Use RuntimeExceptions for exceptions related with unencoded data.

RuntimeExceptions is the correct exception error source is the decoded data.

Note LogicExceptions as defined in PHP documentation implies a modification in the code by the developer.

Exception that represents error in the program logic. This kind of exception should lead directly to a fix in your code.
http://php.net/manual/en/class.logicexception.php

But the token is a data provided by an external source which is out side of the control of the developer so there is no way of prevent malformed tokens.

try {} catch (\Exception) {} // Incorrect

try {} catch (\RuntimeException) {} // Correct

RuntimeExceptions is the correct exception error source is the decoded data.

Note LogicExceptions as defined in PHP documentation implies a modification in the code by the developer.

> Exception that represents error in the program logic. This kind of exception should lead directly to a fix in your code.
http://php.net/manual/en/class.logicexception.php

But the token is a data provided by an external source which is out side of the control of the developer so there is no way of prevent malformed tokens.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@Maks3w
Copy link
Author

Maks3w commented Jan 17, 2016

I won't sign any kind of CLA. This contribution is free of any kind of right I could have.

@robertdimarco
Copy link

Great stuff! Happy to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants