Improve geometry file loading error handling #1753
Open
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Improve geometry file loading error handling
Addresses: #1662
Summary
Adds comprehensive error handling for geometry file loading (CHEASE, FBT, EQDSK) with helpful error messages, file suggestions, and pre-parsing validation.
Problem
Geometry file loading errors were unhelpful:
FileNotFoundErrorwithout contextSolution
1. Custom Exception Hierarchy
2. Modular Error Handling
Created
geometry_error_handling.pymodule with:find_similar_files()- Uses difflib for filename suggestionsvalidate_file_access()- Pre-parsing validationKeeps
geometry_loader.pyfocused on core loading logic.3. Better Error Messages
Before:
After:
4. Format-Specific Validation
5. Logging Integration
Changes
New Files:
geometry_errors.py- Exception classesgeometry_error_handling.py- Helper functionstests/geometry_loader_test.py- Comprehensive tests (15+ cases)Modified Files:
geometry_loader.py- Enhanced with error handlingStats: 3 files changed, 600+ insertions, 50+ deletions
Testing
Backward Compatibility