I'm making a Remote::get request to an API which answers with http 500 when something goes wrong. The thing is that it also gives {errorCode: x} as a more detailed description of what went wrong in the response text. On some of the error codes I need to take different actions.
My problem is that Kohana throws an exception on http 500 responses and thus bakes in my easy parsable response text in a "wordy" error message in the exception object.
Is there some way to get the response text of the Remote::get on a http 500 response without having to parse a lengthy error description?
Impossible. Take a look at source code
Kohana_Exception doesn't help much
So it mixes all things into one message.
How about using different HTTP client? For example Guzzle - it is easier to retrieve the body on error.