Open pirj opened 8 years ago
Yeah, it is unfortunate that the error message isn't being passed but in the meantime, I believe you can retrieve the error message by parsing the response.
begin
client.domain.create('my_app', {hostname: "mydomain.com"})
rescue Excon::Error::UnprocessableEntity => e
JSON.parse(e.response.data[:body])
end
Hope that helps!
Oh, didn't know response is wrapped into exception. That works around the issue, thanks! Should I leave the ticket open until there's a better option to get the error message.
Yeah, if you leave it open I can see about improving the default messaging. Sorry for the difficulties here, but glad you have a reasonable workaround available.
@geemus There are 2 places I could see making this improvement:
1) in heroics, possibly by rescuing some subset of excon errors and re-raising a heroics specific-error instance, and 2) In excon, though that seems to be so widely used that I'd be loath to modify how it throws errors.
Thoughts? Other ideas?
Yeah, I was thinking heroics would probably be the right level/place for it.
It might be a good idea to add such an error response to the example in the README. I wanted to know what happens in case of an error (ie. if an error is raised, or if I have to look at the return value of eg. heroku.dyno.create
), and this is not addressed.
with curl: