Correct and simplify URLError exception handling