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

Make ClientInterface implementations throw an exception on non 2xx HTTP response codes #228

Open
aik099 opened this issue Jan 4, 2025 · 0 comments
Milestone

Comments

@aik099
Copy link
Member

aik099 commented Jan 4, 2025

The current implementation of ClientInterface has several issues:

  • not all error HTTP codes are converted to an exception (e.g. HTTP 401 code is, but others are not)
  • the API response is lost when exception is thrown
  • cURL transport errors (for CurlClient only) aren't handled at all

Proposing to:

  1. throw an exception on any non-2xx HTTP response code
  2. for the \chobie\Jira\Api\Exception class:
    • add the protected rawResponse property, which will be populated from the constructor
    • add public getRawReponse method, that will return the above property
    • add public getResponse method, that will return a json-decoded version of the raw response

This way a developer will be informed about the error (through an exception being thrown) and can do further error analysis using the getResponse method.

@aik099 aik099 added this to the v3.0.0 milestone Jan 4, 2025
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

No branches or pull requests

1 participant