Skip to content

Replace generic exceptions with rich error messages and "did you mean?" suggestions#948

Merged
SkBlaz merged 3 commits intomasterfrom
copilot/improve-error-logs
Dec 25, 2025
Merged

Replace generic exceptions with rich error messages and "did you mean?" suggestions#948
SkBlaz merged 3 commits intomasterfrom
copilot/improve-error-logs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 25, 2025

Replaced basic Python exceptions (ValueError, FileNotFoundError) with domain-specific exceptions that provide constructive suggestions, typo detection, and actionable guidance across 5 high-traffic modules.

Changes

Path algorithms (paths/algorithms.py)

  • AlgorithmError with fuzzy matching for typos
  • Lists valid algorithms when unknown one requested

Robustness centrality (centrality/robustness.py)

  • Parameter validation with usage hints per metric type
  • Target/metric typo suggestions

Workflow configuration (workflows.py)

  • File I/O errors suggest similar files in directory
  • Format errors list valid extensions with use cases
  • YAML dependency errors include pip install command
  • Algorithm/measure selection with "did you mean?"

Temporal utilities (temporal_utils.py)

  • ParsingError explains expected timestamp formats
  • Distinguishes parse failures from type mismatches
  • Provides ISO 8601 and epoch timestamp examples

Attribute correlation (algorithms/attribute_correlation.py)

  • NetworkConstructionError for missing core_network
  • Centrality type suggestions with explanations
  • Correlation method hints (pearson/spearman/kendall)

Example

Before:

ValueError: Unknown path algorithm 'shortest_pth'. Known: shortest_path, all_paths

After:

error[PX301]: algorithm error
   |
   = Path algorithm 'shortest_pth' is not registered

help: did you mean `shortest_path`?
help: available algorithms: all_paths, shortest_path

Uses existing Rust-style error infrastructure from exceptions.py and errors.py. Added 12 tests validating improvements (88 total passing).

Original prompt

This section details on the original issue you should resolve

<issue_title>Better error logs</issue_title>
<issue_description>Improve errors with constructive suggestions, no new md allowed</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 25, 2025 09:15
- Replace ValueError in paths/algorithms.py with AlgorithmError + did-you-mean
- Replace ValueError in centrality/robustness.py with helpful parameter suggestions
- Replace ValueError/FileNotFoundError in workflows.py with rich Py3plex exceptions
- Add comprehensive tests for improved error messages
- All 86 exception tests passing

Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
- Replace ValueError in temporal_utils.py with ParsingError + format hints
- Replace ValueError in attribute_correlation.py with AlgorithmError/NetworkConstructionError
- Add tests for temporal and attribute correlation errors
- All 88 exception tests passing

Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve error logs with constructive suggestions Replace generic exceptions with rich error messages and "did you mean?" suggestions Dec 25, 2025
Copilot AI requested a review from SkBlaz December 25, 2025 09:25
@SkBlaz SkBlaz marked this pull request as ready for review December 25, 2025 18:14
@SkBlaz SkBlaz merged commit 469dfd9 into master Dec 25, 2025
31 checks passed
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.

Better error logs

2 participants