Improve error messages with actionable suggestions #46#64
Improve error messages with actionable suggestions #46#64alexeev-prog merged 10 commits intoalexeev-prog:mainfrom
Conversation
- 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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
And please add comment # type: ignore in import whois line (remove the comment about pip install). This needed for mypy check pass.
|
@zeel2104 thanks for pr, can you apply changes to code from review? |
|
@alexeev-prog |
|
Hey @alexeev-prog |
|
@zeel2104 Thanks for your PR! |
| except Exception as e: | ||
| return [{"error": f"Error fetching WHOIS for {domain}: {e}"}] |
There was a problem hiding this comment.
🔴 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(...)insideexceptblocks" 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.
| 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}"}] |
Was this helpful? React with 👍 or 👎 to provide feedback.
Changes include:
whois_commanddocstring indns_commands.pyto fit a single line according to PEP-257 conventions.formatters.pyto comply with Ruff line-length checks.Testing