相关文章推荐
痛苦的投影仪  ·  前端 - ...·  2 年前    · 
玩手机的楼梯  ·  前端 input ...·  2 年前    · 

Custom ErrorDecoder wraps Exception in java.lang.reflect.UndeclaredThrowableException #386

@flash1293

Description

I tried to implement a custom error-decoder, but Feign doesn't throw the Exception returned by the decoder but a java.lang.reflect.UndeclaredThrowableException which wraps my custom exception:

//...
.errorDecoder(new ErrorDecoder() {
                    @Override
                    public Exception decode(String methodKey, Response response) {
                        if (response.status() == 404) {
                            return new NotFoundException("product not found");
                        return errorStatus(methodKey, response);
//...
try {
   apiProxy.getStuff();
} catch(Throwable t) {
//t is java.lang.reflect.UndeclaredThrowableException, but should be NotFoundException

Is this really the desired behaviour? I expected to see my own exception-class thrown at this point.