测试

发布时间 2023-04-19 17:30:02作者: 小羊摩多摩多
X

import feign.Response;
import feign.RetryableException;
import feign.codec.ErrorDecoder;

public class CustomErrorDecoder implements ErrorDecoder {

    @Override
    public Exception decode(String methodKey, Response response) {
        if (response.status() == 429) {
            return new RetryableException(
                    "Too many requests",
                    null,
                    response.request().httpMethod(),
                    null,
                    response.request());
        }

        return new RuntimeException("Unknown error");
    }
}