nategood/httpful

Send body along with exception when json parsing fails

byrnedo opened this issue · 1 comments

If the body is malformed JSON I can't get access to it if the json_decode throws an exception.

Could the body ( or the first n bytes ) be sent in a custom exception so that they can be inspected/logged?

I ran into the same issue. Looking at the exception thrown when a json decode fails I cannot figure out the reason why. Some of my calls go through proxy servers that return HTML formatted error pages for unknown pages which then comes back as a generic "Unable to parse response as JSON" message making debugging impossible. I have reverted to not using the expectsJson() method and just manually decoding and handling errors.