Skip to content

Improve error messages with actionable suggestions #46#64

Merged
alexeev-prog merged 10 commits intoalexeev-prog:mainfrom
zeel2104:improve_error_messages
Mar 26, 2026
Merged

Improve error messages with actionable suggestions #46#64
alexeev-prog merged 10 commits intoalexeev-prog:mainfrom
zeel2104:improve_error_messages

Conversation

@zeel2104
Copy link
Copy Markdown
Contributor

@zeel2104 zeel2104 commented Mar 24, 2026

Changes include:

  • Updated cli.py and network-related modules to provide specific guidance when commands fail or permissions are insufficient.
  • network_base/traceroute.py - suggest installing missing commands or using sudo for permissions.
  • network_base/whois_lookup.py - suggest installing 'whois' when lookup fails.
  • arp/cache.py - suggest running as root/sudo if permissions prevent operation.
  • security/email_security.py - suggest installing dig/dnspython if required.
  • cli.py - general error handling updated to include actionable guidance in click.ClickException.
  • Adjusted whois_command docstring in dns_commands.py to fit a single line according to PEP-257 conventions.
  • Fixed line wrapping in formatters.py to comply with Ruff line-length checks.
  • Only modified files that were touched during current work.
  • No changes were made to tests or other legacy code.
  • All modified files pass Ruff linting checks.

Testing

  • Tested on google.com and example.com
  • Verified clean table output in terminal


Open with Devin

- Updated cli.py to raise ClickException using 'raise ... from e' for proper exception chaining
- Adjusted whois_command docstring in dns_commands.py to fit a single line
- Fixed line wrapping in formatters.py to comply with Ruff line-length checks
- Only modified files that were touched during current work
- All modified files pass Ruff linting checks
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hello! Tabulate is already integrated (see common_cli_options function), just return list with dicts (you can view examples in this dns_commands file) in command and check the result. Commands return a list, as this allows them to be automatically converted to the desired output formats (table, html, csv, json, yaml, toml). You only need to return the files!

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

And please add comment # type: ignore in import whois line (remove the comment about pip install). This needed for mypy check pass.

@alexeev-prog
Copy link
Copy Markdown
Owner

@zeel2104 thanks for pr, can you apply changes to code from review?

devin-ai-integration[bot]

This comment was marked as resolved.

@zeel2104
Copy link
Copy Markdown
Contributor Author

@alexeev-prog
Applied the requested review changes and fixed the failing tests. Local checks are passing now. Please take another look when you have a chance.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@zeel2104
Copy link
Copy Markdown
Contributor Author

Hey @alexeev-prog
I’ve done several follow up passes on this PR and addressed the latest review feedback, but I’m still hitting iterative review churn. If it would be more efficient, I’m happy for this to be reassigned to someone more familiar with the project’s preferred structure so it can be finished cleanly. Thank you

@alexeev-prog alexeev-prog merged commit 6d8c105 into alexeev-prog:main Mar 26, 2026
4 of 5 checks passed
@alexeev-prog
Copy link
Copy Markdown
Owner

@zeel2104 Thanks for your PR!

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

Comment on lines +139 to +140
except Exception as e:
return [{"error": f"Error fetching WHOIS for {domain}: {e}"}]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Missing logger.exception() in whois_domain_lookup except block violates mandatory logging rules

The except Exception block at src/nadzoring/network_base/whois_lookup.py:139-140 silently converts the exception to a return value without calling logger.exception(). This violates two mandatory repository rules:

  • CONTRIBUTING.md: "Use logger.exception(...) inside except blocks" and "Never swallow exceptions silently; always log or re-raise"
  • .cursor/rules/nadzoring.mdc: "Always use logger.exception() inside except blocks—it automatically captures and includes the traceback"

Every other except block in the same file (whois_lookup.py:67-68) and throughout network_base/ consistently uses logger.exception(). The traceback is lost, making debugging failed WHOIS lookups significantly harder.

Suggested change
except Exception as e:
return [{"error": f"Error fetching WHOIS for {domain}: {e}"}]
except Exception as e:
logger.exception("WHOIS domain lookup failed for %s", domain)
return [{"error": f"Error fetching WHOIS for {domain}: {e}"}]
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants