Commit 06b438a9 by 刘宇峰

框架完善

1 parent c975a8b9
package com.glsx.plat.exception;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import java.io.Serializable;
......@@ -9,9 +8,8 @@ import java.io.Serializable;
/**
* @author payu
*/
@Setter
@Getter
@Slf4j
@Data
public class ServiceException extends RuntimeException implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -19,12 +17,15 @@ public class ServiceException extends RuntimeException implements Serializable {
private String msg;
private String code;
public ServiceException(String code, String msg) {
super(msg);
this.code = code;
this.msg = msg;
}
public static ServiceException create(String code, String msg) {
log.error("Service RuntimeException {} {}", code, msg);
ServiceException exception = new ServiceException();
exception.setCode(code);
exception.setMsg(msg);
return exception;
return new ServiceException(code, msg);
}
}
......@@ -68,10 +68,10 @@ public class RestTemplateRequestInterceptor implements ClientHttpRequestIntercep
.resStatus(responseCopy.getRawStatusCode())
.build()));
// JSONObject resultJO = JSONUtil.parseObj(reqBody);
// if (!Objects.equals(SysConstants.ResultStatus.success.getCode(), resultJO.get("code"))) {
// throw ServiceException.create(resultJO.getStr("code"), resultJO.getStr("message"));
// }
JSONObject resultJO = JSONUtil.parseObj(resBody);
if (!Objects.equals(SysConstants.ResultStatus.success.getCode(), resultJO.get("code"))) {
throw ServiceException.create(resultJO.getStr("code"), resultJO.getStr("message"));
}
return responseCopy;
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!