title: URLLIB.REQUEST.URLOPEN Exception handles
body: <p>Im having problems with the error handling of the following code. Im testing for exception handling.
  If i invalidate the filename to something like &quot;stat.xml: the error code exception is thrown. Error code:  404.</p>
  <p>If I invalidate any part of the top_level_url the code crashes. But still seems to throw a 404, just deeper into the libs. This code will be querying a remote device, if that device is inaccessible i need to error and retry not crash.</p>
  <blockquote>
  <p>Traceback (most recent call last):
  File &quot;C:\Users-\PycharmProjects-\Detection.py&quot;, line 81, in 
  opener.open(top_level_url + &quot;/status.xml&quot;)
  File &quot;C:\Users-\AppData\Local\Programs\Python\Python310\lib\urllib\request.py&quot;, line 525, in open
  response = meth(req, response)
  File &quot;C:\Users-\AppData\Local\Programs\Python\Python310\lib\urllib\request.py&quot;, line 634, in http_response
  response = self.parent.error(
  File &quot;C:\Users-\AppData\Local\Programs\Python\Python310\lib\urllib\request.py&quot;, line 563, in error
  return self._call_chain(*args)
  File &quot;C:\Users-\AppData\Local\Programs\Python\Python310\lib\urllib\request.py&quot;, line 496, in _call_chain
  result = func(*args)
  File &quot;C:\Users-\AppData\Local\Programs\Python\Python310\lib\urllib\request.py&quot;, line 643, in http_error_default
  raise HTTPError(req.full_url, code, msg, hdrs, fp)
  urllib.error.HTTPError: HTTP Error 404: Not Found</p>
  </blockquote>
  <p>Process finished with exit code 1</p>
  <pre><code>    try:
          data = urllib.request.urlopen(top_level_url + &quot;/status.xml&quot;)
          urllib.request.build_opener(handler)
      except HTTPError as e:
          # do something
          print('Error code: ', e.code)
          exit()
      except URLError as e:
          # do something
          print('Reason: ', e.reason)
          exit()
      else:
          # do something
          print('Connected to Panel')
  </code></pre>