Better error handling for urlopen() method for network check