diff --git a/tests/host_tools/network.py b/tests/host_tools/network.py index 787bc080c17..7d2e5cf6a5b 100644 --- a/tests/host_tools/network.py +++ b/tests/host_tools/network.py @@ -58,7 +58,13 @@ def __init__(self, netns, ssh_key: Path, host, user, *, on_error=None): # _init_connection loops until it can connect to the guest # dumping debug state on every iteration is not useful or wanted, so # only dump it once if _all_ iterations fail. - self._init_connection() + try: + self._init_connection() + except Exception as exc: + if on_error: + on_error(exc) + + raise self._on_error = on_error