[errors] Improve error handling by using DeciMojoError type
#114
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.
This pull request introduces significant improvements and error handling enhancements for arithmetic operations in the
BigIntandBigUInttypes. Key changes include the removal of theraiseskeyword from function signatures, the addition of structured error handling using custom error types, and improvements to the implementation of arithmetic operations to ensure correctness and maintainability.Improved Error Handling
Introduced custom error types such as
DeciMojoError,OverflowError, andZeroDivisionErroracross the codebase for more structured and descriptive error reporting. For example, division and modulo operations now raiseZeroDivisionErrorwhen dividing by zero.Replaced generic error messages with detailed exceptions that include contextual information such as the file, function, and previous error, improving debugging and traceability.
Update TOML parser
Enhancements to Arithmetic Operations
Removed the
raiseskeyword from all arithmetic function signatures insrc/decimojo/bigint/arithmetics.mojoandsrc/decimojo/biguint/arithmetics.mojo. This simplifies the function definitions while maintaining error handling through explicit exceptions.Updated the
add_inplace,subtract, andmultiplyfunctions insrc/decimojo/bigint/arithmetics.mojoto use helper functions likenegativeandsubtract_inplace_no_checkfor better clarity and modularity.Updates to BigInt Struct Methods
Updated operator overloading methods (e.g.,
__add__,__sub__,__mul__) insrc/decimojo/bigint/bigint.mojoto remove theraiseskeyword and include structured error handling where applicable.Enhanced in-place operators like
__iadd__and__isub__to directly call the updated arithmetic functions, ensuring consistency with the new error handling approach.Codebase-Wide Improvements
Added
.gitattributesconfiguration to enforce LF (Unix-style) line endings for consistency across the project.Improved modularity by importing
DeciMojoErrorin relevant files such assrc/decimojo/bigint/bigint.mojoandsrc/decimojo/biguint/arithmetics.mojo.These changes collectively improve the robustness, readability, and maintainability of the codebase while introducing a more structured approach to error handling for arithmetic operations.