本文整理匯總了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));
}