Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.