Skip to content

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

@aik099

Description

@aik099

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.


Also TODO:
Remove code, that is handling errors from the \chobie\Jira\Api::findVersionByName method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions