Stack Exchange
Netflix Feign custom error decoder doesn't work correctly
I have a problem with custom error decoder in netflix Feign. 
I have a service A and a service B , service A is sending something to service B :
@FeignClient(value = "A", url = "${B.url}", configuration = MyConfig.class)
public interface NotificationClient {
     @DeleteMapping(value = "/somepath", consumes = MediaType.APPLICATION_JSON_VALUE)
     ResponseEntity<Void> sendSomething(MyObject myObject);
}

And MyConfig looks like: 
@Configuration
public class MyConfig {

    @Bean
    ErrorDecoder errorDecoder() {
        return new MyErrorDecoder();
    }
}

And MyErrorDecoder :
public class MyErrorDecoder implements ErrorDecoder {

@Override
public Exception decode(String methodKey, Response response) {

    if (response.status() >= 400 && response.status() <= 499) {
        return new MyClientException(response.status(), response.reason(), response.request().url());
    }

    if (response.status() >= 500 && response.status() <= 599) {
        return new MyServerException(response.status(), response.reason(), response.request().url());
    }

    return errorStatus(methodKey, response);
}
}

And for example MyClientException :
@Getter
public class MyClientException extends RuntimeException {

private static final long serialVersionUID = 8021218722733395779L;

private final int httpStatusCode;

public MyClientException(int status, String reason, String url){
    super(String.format("Error when sending request to: ' %s ' : status: %d %s", url, status, reason != null ? reason : ""));
    this.httpStatusCode = status;
}
}

My problem is that I have a validation in service 'B', and it returns http status code 400, but in my service 'A' i got status 500 and message like "Error when sending request to: ' url_from_properties/somepath ' : status: 400 ".. why? I want to have the same status code in service 'A' what i got in service 'B'. 
I looking for answer but nothing works exactly like i expect. What is wrong here?

can you post the full exception?

@spencergibb Yes, I'm using swagger and i got this:
{
"timestamp": "2019-10-23T14:23:04.256+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Error when sending notification to: ' http://localhost:8080/B_URL/somepath ' : status: 400 ",
"path": "/order-module/test123"
}
