你可以假装
ErrorDeprer
https://github.com/OpenFeign/feign/wiki/Custom-error-
handling
这是一个例子
public class MyErrorDeprer implements ErrorDeprer { private final ErrorDeprer defaultErrorDeprer = new Default(); @Override public Exception depre(String methodKey, Response response) { if (response.status() >= 400 && response.status() <= 499) { return new MyBadRequestException(); } return defaultErrorDeprer.depre(methodKey, response); }}
为了让Spring能够使用ErrorDeprer,必须将其放在ApplicationContext上:
@Beanpublic MyErrorDeprer myErrorDeprer() { return new MyErrorDeprer();}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)