Commit d0e10279 authored by suhuiguang's avatar suhuiguang

1.修改错误

parent 5860c7b7
...@@ -4,24 +4,26 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,24 +4,26 @@ import com.alibaba.fastjson.JSONObject;
import feign.Response; import feign.Response;
import feign.Util; import feign.Util;
import feign.codec.ErrorDecoder; import feign.codec.ErrorDecoder;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException; import java.io.IOException;
/** /**
* @author DELL * @author DELL
*/ */
@Slf4j
public class FeignErrorDecoder implements ErrorDecoder { public class FeignErrorDecoder implements ErrorDecoder {
@Override @Override
public Exception decode(String s, Response response) { public Exception decode(String methodKey, Response response) {
String msg = null; String msg = null;
try { try {
msg = Util.toString(response.body().asReader()); msg = Util.toString(response.body().asReader(Util.UTF_8));
JSONObject object = JSONObject.parseObject(msg);
throw new RuntimeException(object.get("devMessage").toString());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); log.error("feign 调用失败" + e.getMessage());
} }
JSONObject object = JSONObject.parseObject(msg); throw new RuntimeException(methodKey + "远程调用失败");
throw new RuntimeException(object.get("devMessage").toString());
} }
} }
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