Skip to content
Robert Brodie edited this page Apr 27, 2024 · 1 revision

When making requests, it's possible to receive an HTTPError. There have been various discussions and questions related to this, so we wanted to provide a concrete example.

Example

A real-world example is that of trying to fetch an issue that does not exist. To handle this, we can rescue the exception and inspect it to see what the response is.

begin
  client.Issue.find('NOEXIST-2')
rescue => e
  puts JSON.parse(e.response.body.inspect)
end

As long as there is no issue with the key NOEXIST-2, we'll see the response from Jira which will look like this:

{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}
Clone this wiki locally