Skip to content

[error] Remove redundant Error wrappers + Add RuntimeError type + Replace DecimoError with specific error types#198

Merged
forfudan merged 3 commits intodevfrom
error
Apr 9, 2026
Merged

[error] Remove redundant Error wrappers + Add RuntimeError type + Replace DecimoError with specific error types#198
forfudan merged 3 commits intodevfrom
error

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Apr 9, 2026

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 RuntimeError as a DecimoError[...] alias and update runtime-infrastructure failure sites (e.g., MPFR availability/allocation).
  • Replace uses of the generic DecimoError wrapper with more specific error types (and update tests to match).

@forfudan forfudan changed the title [error] Remove redundant Error wrappers + Replace DecimoError with more specific error types [error] Remove redundant Error wrappers + Add RuntimeError type + Replace DecimoError with specific error types Apr 9, 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 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 RuntimeError as a DecimoError[...] alias and update runtime-infrastructure failure sites (e.g., MPFR availability/allocation).
  • Replace uses of the generic DecimoError wrapper 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.

Comment thread src/decimo/biguint/biguint.mojo Outdated
Comment thread src/decimo/biguint/biguint.mojo Outdated
Comment thread src/decimo/biguint/arithmetics.mojo
Comment thread src/decimo/decimal128/arithmetics.mojo Outdated
Comment thread src/decimo/decimal128/arithmetics.mojo Outdated
Comment thread src/decimo/decimal128/exponential.mojo Outdated
Comment thread src/decimo/decimal128/exponential.mojo Outdated
Comment thread src/decimo/biguint/arithmetics.mojo
@forfudan forfudan merged commit 2cf5e0f into dev Apr 9, 2026
11 checks passed
@forfudan forfudan deleted the error branch April 9, 2026 20:22
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