本文整理汇总了Java中java.net.ConnectException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectException.getMessage方法的具体用法?Java ConnectException.getMessage怎么用?Java ConnectException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.ConnectException
的用法示例。
在下文中一共展示了ConnectException.getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleConnectException
import java.net.ConnectException; //导入方法依赖的package包/类
private void handleConnectException(ConnectException e) throws ConnectException {
String message = e.getMessage();
String[] tokens = message.split("-");
if (tokens.length > 1 && tokens[1] != null) {
Timber.e(e, "Stripping host/port from ConnectionException for %s", getLogId());
throw new ConnectException(tokens[1].trim());
} else {
throw e;
}
}
示例2: runCheck
import java.net.ConnectException; //导入方法依赖的package包/类
private void runCheck(CloseableHttpClient client, Check check) throws Exception {
String lastFailure = null;
HttpGet get = new HttpGet(check.getUrl());
for (int i = 0; i < TRIES; i++) {
try (CloseableHttpResponse response = client.execute(get)) {
if (response.getStatusLine().getStatusCode() != 200) {
lastFailure = "Status code is " + response.getStatusLine();
Thread.sleep(WAIT_BETWEEN_TRIES_MILLIS);
continue;
}
lastFailure = check.runCheck(response);
if (lastFailure == null) {
return;
}
} catch ( ConnectException e ) {
lastFailure = e.getClass().getName() + " : " + e.getMessage();
}
Thread.sleep(WAIT_BETWEEN_TRIES_MILLIS);
}
throw new RuntimeException(String.format("Launchpad not ready. Failed check for URL %s with message '%s'",
check.getUrl(), lastFailure));
}