[error] Remove redundant Error wrappers + Add RuntimeError type + Replace DecimoError with specific error types#198
Merged
Conversation
Error wrappers + Replace DecimoError with more specific error typesError wrappers + Add RuntimeError type + Replace DecimoError with specific error types
There was a problem hiding this comment.
Pull request overview
This PR refactors Decimo’s error-handling to raise the library’s typed DecimoError[...] aliases directly (e.g., ValueError, OverflowError) instead of wrapping them in Error(...), introduces a RuntimeError type, and updates call sites/tests accordingly.
Changes:
- Remove redundant
Error(...)wrappers across TOML parsing, numeric parsing, and arithmetic modules. - Add
RuntimeErroras aDecimoError[...]alias and update runtime-infrastructure failure sites (e.g., MPFR availability/allocation). - Replace uses of the generic
DecimoErrorwrapper with more specific error types (and update tests to match).
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/decimo/toml/parser.mojo | Raises ValueError directly for TOML parse/path/key errors. |
| src/decimo/tests.mojo | Updates test helper to rethrow parse failures using ValueError alias. |
| src/decimo/str.mojo | Raises ValueError directly for numeric-string parsing validation errors. |
| src/decimo/errors.mojo | Adds RuntimeError alias; changes DecimoError generic param to StringLiteral. |
| src/decimo/decimal128/special.mojo | Raises typed errors directly for factorial bounds/overflow. |
| src/decimo/decimal128/rounding.mojo | Raises OverflowError directly for rounding overflow conditions. |
| src/decimo/decimal128/exponential.mojo | Replaces DecimoError wrappers; rethrows failures with typed errors. |
| src/decimo/decimal128/decimal128.mojo | Removes DecimoError wrapper usage; uses ConversionError/ValueError/OverflowError. |
| src/decimo/decimal128/constants.mojo | Raises ValueError directly for invalid constant lookup input. |
| src/decimo/decimal128/arithmetics.mojo | Raises typed errors directly for arithmetic failures; adjusts rethrowing. |
| src/decimo/biguint/biguint.mojo | Removes DecimoError wrappers; adjusts dunder error rethrows and imports. |
| src/decimo/biguint/arithmetics.mojo | Removes DecimoError wrappers; uses typed errors for arithmetic edge cases. |
| src/decimo/bigint10/bigint10.mojo | Removes DecimoError wrappers; uses ConversionError/ZeroDivisionError where relevant. |
| src/decimo/bigint10/arithmetics.mojo | Removes DecimoError wrappers; rethrows division/modulo failures with ZeroDivisionError. |
| src/decimo/bigint/number_theory.mojo | Replaces DecimoError with ValueError for invalid modular arithmetic inputs. |
| src/decimo/bigint/exponential.mojo | Replaces DecimoError with ValueError for invalid sqrt input. |
| src/decimo/bigint/bigint.mojo | Removes DecimoError wrappers; uses ZeroDivisionError for division-related dunders. |
| src/decimo/bigint/arithmetics.mojo | Removes DecimoError wrappers; uses ValueError/ZeroDivisionError for invalid operations. |
| src/decimo/bigfloat/bigfloat.mojo | Uses new RuntimeError for MPFR availability/allocation failures; keeps ConversionError for parsing/export. |
| src/decimo/bigdecimal/trigonometric.mojo | Raises ValueError directly for undefined trig reciprocals. |
| src/decimo/bigdecimal/exponential.mojo | Raises typed errors directly for invalid power/root/log inputs and overflow. |
| src/decimo/bigdecimal/constants.mojo | Raises ValueError directly for invalid precision. |
| src/decimo/bigdecimal/bigdecimal.mojo | Removes DecimoError wrappers; uses ConversionError/ValueError directly. |
| src/decimo/bigdecimal/arithmetics.mojo | Raises ZeroDivisionError directly for division/modulo by zero. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR refactors Decimo’s error-handling to raise the library’s typed
DecimoError[...]aliases directly (e.g.,ValueError,OverflowError) instead of wrapping them inError(...), introduces aRuntimeErrortype, and updates call sites/tests accordingly.Changes:
Error(...)wrappers across TOML parsing, numeric parsing, and arithmetic modules.RuntimeErroras aDecimoError[...]alias and update runtime-infrastructure failure sites (e.g., MPFR availability/allocation).DecimoErrorwrapper with more specific error types (and update tests to match).