Refactoing: Replace Error Code with Exception
continuous-integration/drone/push Build is failing Details

This commit is contained in:
qvalentin 2022-05-27 09:32:34 +02:00
parent 71b28222a7
commit 7fbc3f722c
Signed by: qvalentin
GPG Key ID: C979FA1EAFCABF1C
1 changed files with 7 additions and 1 deletions

View File

@ -1,7 +1,10 @@
package link;
import exeptions.URLIsNotReachable;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.UnknownHostException;
public class OnlineCheck {
@ -18,8 +21,11 @@ public class OnlineCheck {
return http.getResponseCode();
}
catch (UnknownHostException unknownHostException){
throw new URLIsNotReachable("The host of the url " + url + " could not be resolved.");
}
catch (IOException e) {
return 500; //TODO: seems smelly
throw new URLIsNotReachable("Something went wrong when trying to check if the url " + url + " is reachable. Make sure your internet connection is working: " + e.getMessage());
}
}
}