Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 592 forks source link

When parsing an error body allow for non-parsing error bodies #308

Closed ryber closed 4 years ago

ryber commented 4 years ago

Describe the bug The error mapper function expects the only possibly source of a body to parse would be in the parsing exception. This is not the case if the body actually parsed correctly or the Object Mapper was extra laissez faire

To Reproduce

   @Test
    public void parsingAnAlternativeErrorObject_StringBody() {
        ErrorThing e = Unirest.get(MockServer.ERROR_RESPONSE)
                .asString()
                .mapError(ErrorThing.class);

        assertErrorThing(e);
    }