|
@@ -18,6 +18,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
+import java.net.ConnectException;
|
|
|
+
|
|
|
import static cn.com.qmth.examcloud.app.model.Constants.*;
|
|
|
|
|
|
/**
|
|
@@ -74,7 +76,13 @@ public class HttpUtils {
|
|
|
}
|
|
|
|
|
|
public static Result<String> call(Request request) throws Exception {
|
|
|
- Response response = HttpClientBuilder.getClient().newCall(request).execute();
|
|
|
+ Response response;
|
|
|
+ try {
|
|
|
+ response = HttpClientBuilder.getClient().newCall(request).execute();
|
|
|
+ } catch (ConnectException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ return new Result<>().error("服务访问失败!");
|
|
|
+ }
|
|
|
String bodyStr = response.body().string();
|
|
|
if (response.isSuccessful()) {
|
|
|
return new Result().success(bodyStr);
|