Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Do not crash with stack trace on expectable error #647

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/gallia/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ def net_if_addrs() -> list[Interface]:
if sys.platform != "linux":
raise NotImplementedError("net_if_addrs() is only supported on Linux platforms")

p = subprocess.run(["ip", "-j", "address", "show"], capture_output=True, check=True)
try:
p = subprocess.run(["ip", "-j", "address", "show"], capture_output=True, check=True)
except FileNotFoundError as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception type means, that the ip tool is not available, right? I would state this in the error message as such.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, never mind. This should be included in {e}.

logger.warning(f"Could not query information about interfaces: {e}")
return []

try:
return [Interface(**item) for item in json.loads(p.stdout.decode())]
Expand Down
Loading