Commit d0e10279 authored by suhuiguang's avatar suhuiguang

1.修改错误

parent 5860c7b7
......@@ -4,24 +4,26 @@ import com.alibaba.fastjson.JSONObject;
import feign.Response;
import feign.Util;
import feign.codec.ErrorDecoder;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
/**
* @author DELL
*/
@Slf4j
public class FeignErrorDecoder implements ErrorDecoder {
@Override
public Exception decode(String s, Response response) {
public Exception decode(String methodKey, Response response) {
String msg = null;
try {
msg = Util.toString(response.body().asReader());
} catch (IOException e) {
e.printStackTrace();
}
msg = Util.toString(response.body().asReader(Util.UTF_8));
JSONObject object = JSONObject.parseObject(msg);
throw new RuntimeException(object.get("devMessage").toString());
} catch (IOException e) {
log.error("feign 调用失败" + e.getMessage());
}
throw new RuntimeException(methodKey + "远程调用失败");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment