Skip to content

Commit 33bb0da

Browse files
committed
utils/vmimage: Handle URLError in addition to HTTPError
Add URLError to exception handling in _feed_html_parser() to catch DNS resolution failures and other network errors that don't result in an HTTP response. Also add debug logging for network errors to aid troubleshooting. Reference: avocado-framework#6266 Assisted-By: Cursor-Claude-4-Sonnet Signed-off-by: Harvey Lynden <hlynden@redhat.com>
1 parent fdf8aee commit 33bb0da

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

avocado/utils/vmimage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import uuid
2424
import warnings
2525
from html.parser import HTMLParser
26-
from urllib.error import HTTPError
26+
from urllib.error import HTTPError, URLError
2727
from urllib.request import urlopen
2828

2929
from avocado.utils import archive, asset, astring
@@ -118,7 +118,8 @@ def _feed_html_parser(self, url, parser):
118118
with urlopen(url) as u:
119119
data = u.read()
120120
parser.feed(astring.to_text(data, self.HTML_ENCODING))
121-
except HTTPError as exc:
121+
except (HTTPError, URLError) as exc:
122+
LOG.debug("Network error accessing %s: %s", url, exc)
122123
raise ImageProviderError(f"Network error: Cannot open {url}") from exc
123124

124125
@staticmethod

0 commit comments

Comments
 (0)