You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
876 B

package exception;
public class NetworkException extends CrawlerException {
public NetworkException(String message) {
super(message);
}
public NetworkException(String message, Throwable cause) {
super(message, cause);
}
public static NetworkException connectionFailed(String host) {
return new NetworkException("网络连接失败,无法访问: " + host,
new java.net.ConnectException("Connection refused"));
}
public static NetworkException unknownHost(String host) {
return new NetworkException("无法解析域名: " + host,
new java.net.UnknownHostException(host));
}
public static NetworkException timeout(String host) {
return new NetworkException("请求超时,无法访问: " + host,
new java.net.SocketTimeoutException("Read timed out"));
}
}