Skip to content

FeignException contains request- or response-body #920

Description

@robachmann

While working on #912 I came across an odd behaviour:

In errorStatus a FeignException is created with the response's body:

body = Util.toByteArray(response.body().asInputStream());

In errorReading a FeignException is created with the request's body (even though the response with its body would be at hand):

I think it's inconsistent and confusing for the user as he or she can't rely on the same data-source for all exceptions. On the other hand, I'm not sure whether it's intentional as there are unit-tests that check this behaviour, thus changing it could also be breaking-change for users:

assertThat(e.contentUTF8()).isEqualTo("Request body");

If we agree on returning the response-body, I'd gladly create a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationIssues that require updates to our documentation

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions