-
Notifications
You must be signed in to change notification settings - Fork 183
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
Improve exceptions #300
Improve exceptions #300
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the idea! 👍
Thank you. I will finalize the PR. Btw what do you think about replacing travic-ci with Github Actions? |
I've found two more cases where exceptions can be thrown and added two new Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR is ready for review. Please take a special look at the wording in the docs. 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice! Thanks for this big PR and sorry for the late review.
Only minor comments, you could decide not to address them! :)
Co-authored-by: Kevin Saliou <kevin@saliou.name>
At the moment I have the problem that exceptions thrown by the library cannot be distinguished from other exceptions thrown for other reasons. This makes testing with the library a bit harder.
At the moment we throw only two different exceptions:
\Exception
, when something fails during the transfer to Redmine or if an API parameter is invalid or missing\InvalidArgumentException
when a non-existent API is requested from the client.This PR introduces these new exceptions that extend the previous exceptions:
\Redmine\Exception\ClientException
replaces\Exception
in CurlClient and Psr18Client.\Redmine\Exception\InvalidApiNameException
replaces\InvalidArgumentException('... is not a valid api. Possible apis are ...')
.\Redmine\Exception\MissingParameterException
replaces\Exception('Missing mandatory parameters')
.\Redmine\Exception\InvalidParameterException
replaces\Exception('Possible values for ...')
.Additionally these new exceptions implement the interface
\Redmine\Exception
.This makes it easier to catch only the exceptions thrown by the Redmine library. Nevertheless, we preserve backward compatibility.
What do you think, @kbsali? If you like the idea, I will create new tests for the new exceptions.