|
@@ -20,6 +20,7 @@ import cn.com.qmth.examcloud.api.commons.exchange.BaseRequest;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.FormFilePart;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.FormFilePart;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.FormRequest;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.FormRequest;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
|
|
import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
|
|
|
|
+import cn.com.qmth.examcloud.commons.exception.ExamCloudRuntimeException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
@@ -29,6 +30,7 @@ import cn.com.qmth.examcloud.commons.util.SHA256;
|
|
import cn.com.qmth.examcloud.commons.util.StringUtil;
|
|
import cn.com.qmth.examcloud.commons.util.StringUtil;
|
|
import cn.com.qmth.examcloud.commons.util.ThreadLocalUtil;
|
|
import cn.com.qmth.examcloud.commons.util.ThreadLocalUtil;
|
|
import cn.com.qmth.examcloud.web.config.LogProperties;
|
|
import cn.com.qmth.examcloud.web.config.LogProperties;
|
|
|
|
+import cn.com.qmth.examcloud.web.exception.ApiFlowLimitedException;
|
|
import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
import cn.com.qmth.examcloud.web.support.StatusResponse;
|
|
import cn.com.qmth.examcloud.web.support.StatusResponse;
|
|
|
|
|
|
@@ -131,9 +133,14 @@ public abstract class CloudClientSupport {
|
|
}
|
|
}
|
|
T t = JsonUtil.fromJson(body, responseType);
|
|
T t = JsonUtil.fromJson(body, responseType);
|
|
return t;
|
|
return t;
|
|
- } else {
|
|
|
|
|
|
+ } else if (HttpStatus.INTERNAL_SERVER_ERROR == respEntity.getStatusCode()) {
|
|
StatusResponse sr = JsonUtil.fromJson(body, StatusResponse.class);
|
|
StatusResponse sr = JsonUtil.fromJson(body, StatusResponse.class);
|
|
throw new StatusException(sr.getCode(), sr.getDesc());
|
|
throw new StatusException(sr.getCode(), sr.getDesc());
|
|
|
|
+ } else if (HttpStatus.SERVICE_UNAVAILABLE == respEntity.getStatusCode()) {
|
|
|
|
+ StatusResponse sr = JsonUtil.fromJson(body, StatusResponse.class);
|
|
|
|
+ throw new ApiFlowLimitedException(sr.getCode(), sr.getDesc());
|
|
|
|
+ } else {
|
|
|
|
+ throw new ExamCloudRuntimeException("unexpected http status code");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -219,6 +226,11 @@ public abstract class CloudClientSupport {
|
|
INTERFACE_LOG.info(StringUtil.join("[CALL-OK]. url=" + url,
|
|
INTERFACE_LOG.info(StringUtil.join("[CALL-OK]. url=" + url,
|
|
" ; cost " + (System.currentTimeMillis() - startTime), " ms."));
|
|
" ; cost " + (System.currentTimeMillis() - startTime), " ms."));
|
|
}
|
|
}
|
|
|
|
+ } catch (ApiFlowLimitedException e) {
|
|
|
|
+ INTERFACE_LOG.error(StringUtil.join("[CALL-FAIL]. url=" + url,
|
|
|
|
+ " ; cost " + (System.currentTimeMillis() - startTime), " ms."));
|
|
|
|
+ INTERFACE_LOG.error("[CALL-RESP]. response=" + e.toJson());
|
|
|
|
+ throw e;
|
|
} catch (StatusException e) {
|
|
} catch (StatusException e) {
|
|
INTERFACE_LOG.error(StringUtil.join("[CALL-FAIL]. url=" + url,
|
|
INTERFACE_LOG.error(StringUtil.join("[CALL-FAIL]. url=" + url,
|
|
" ; cost " + (System.currentTimeMillis() - startTime), " ms."));
|
|
" ; cost " + (System.currentTimeMillis() - startTime), " ms."));
|