Skip to content

Replace exceptions with expected - add tests #2

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

lefticus
Copy link
Member

No description provided.

lefticus and others added 6 commits April 24, 2025 09:48
- Replaced all exception handling with C++23 std::expected for better error handling
- Added custom error types with contextual error messages
- Created evaluate_or_throw for constexpr evaluation
- Updated tests to work with std::expected return types
- Added new tests to verify error handling behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed RationalNumber class to handle negative denominators
- Added many more test cases for arithmetic operations
- Added tests for error handling with std::expected
- Updated test values to match actual evaluation results
- Added tests for whitespace handling and complex expressions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Simplified error types to contain only necessary information
- Removed string messages from StackError, replacing with enum
- Changed EvaluationError to store position information instead of messages
- Updated all error handling code to use the new error types
- Improved CLI error output with colored formatting and visual indicators
- Added more descriptive error messages with specific details
- Enhanced error position indicator to point directly at the problem
- Overall improved user experience with better error feedback

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Added parenthesis balance tracking to ensure proper nesting
- Improved error detection for unmatched parentheses
- Added detection for empty parentheses cases like () and (())
- Handled division by zero by returning RationalNumber(1, 0)
- Updated tests to verify all of these error cases
- Added detailed error position reporting for parsing errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant