Skip to content

feat: Add Python exception classes for structured error handling (Pha…#18

Merged
shaia merged 1 commit intomasterfrom
feature/error-handling-api
Jan 2, 2026
Merged

feat: Add Python exception classes for structured error handling (Pha…#18
shaia merged 1 commit intomasterfrom
feature/error-handling-api

Conversation

@shaia
Copy link
Copy Markdown
Owner

@shaia shaia commented Jan 2, 2026

…se 4)

Add exception hierarchy for CFD error codes with proper Python integration:

  • CFDError base class with status_code and message attributes
  • CFDMemoryError, CFDInvalidError, CFDIOError inherit from builtin types
  • CFDUnsupportedError, CFDDivergedError, CFDMaxIterError for solver errors
  • raise_for_status() helper to convert status codes to exceptions

…se 4)

Add exception hierarchy for CFD error codes with proper Python integration:
- CFDError base class with status_code and message attributes
- CFDMemoryError, CFDInvalidError, CFDIOError inherit from builtin types
- CFDUnsupportedError, CFDDivergedError, CFDMaxIterError for solver errors
- raise_for_status() helper to convert status codes to exceptions
@shaia shaia requested a review from Copilot January 2, 2026 15:28
@shaia shaia self-assigned this Jan 2, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a comprehensive Python exception hierarchy for structured error handling in the CFD library, providing type-safe error propagation and integration with Python's built-in exception system.

Key Changes:

  • Added CFDError base exception class with status_code and message attributes for all CFD-related errors
  • Created specialized exception classes (CFDMemoryError, CFDInvalidError, CFDIOError, CFDUnsupportedError, CFDDivergedError, CFDMaxIterError) with appropriate inheritance from both CFDError and built-in Python exception types
  • Implemented raise_for_status() helper function to automatically convert CFD status codes into appropriate exceptions with context-aware error messages

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
cfd_python/_exceptions.py New module defining the complete exception hierarchy with 7 exception classes, status-to-exception mapping, and the raise_for_status() helper function
cfd_python/__init__.py Imports and exports all exception classes and raise_for_status() function in the public API
tests/test_errors.py Comprehensive test suite covering exception class attributes, inheritance patterns, raise_for_status() behavior for all error codes, and proper module exports
MIGRATION_PLAN.md Updates Phase 4 section to reflect completion status, implementation details, and actual effort (<0.5 days)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@shaia shaia merged commit 76d6d99 into master Jan 2, 2026
21 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.

2 participants