Catch exceptions thrown with urlopen