I'm trying to write clean code, but I'm not so good with exception handling. How can I improve this method? Or is it good enough already?
This method gets a hash from a file.
public String getLatestHash() {
String hash = "none";
URL packURL = null;
try {
packURL = new URL(ConfigManager.get("play_url") + "/" + HTMLParser.getPackName());
} catch (MalformedURLException e) {
logger.severe("invalid URL!");
logger.severe(e.getMessage());
}
try (InputStream inputStream = packURL.openConnection().getInputStream()) {
hash = DigestUtils.md5Hex(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
return hash;
}
packURL
if you get aMalformedURLException
? \$\endgroup\$