Skip to content

[error] Make message and function fields mandatory for DecimoError type#196

Merged
forfudan merged 1 commit intodevfrom
error
Apr 9, 2026
Merged

[error] Make message and function fields mandatory for DecimoError type#196
forfudan merged 1 commit intodevfrom
error

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Apr 9, 2026

This PR updates Decimo’s structured error type so that DecimoError always includes a message and function, ensuring tracebacks consistently show both fields (alongside auto-captured file/line).

Changes:

  • Make DecimoError.message and DecimoError.function mandatory (non-optional) and require them in __init__.
  • Update error construction call sites across parsing, numeric parsing, and numeric types to pass message + function.
  • Convert a couple of previously string-raised errors to structured ValueError instances to comply with the new contract.

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 updates Decimo’s structured error type so that DecimoError always includes a message and function, ensuring tracebacks consistently show both fields (alongside auto-captured file/line).

Changes:

  • Make DecimoError.message and DecimoError.function mandatory (non-optional) and require them in __init__.
  • Update error construction call sites across parsing, numeric parsing, and numeric types to pass message + function.
  • Convert a couple of previously string-raised errors to structured ValueError instances to comply with the new contract.

Reviewed changes

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

Show a summary per file
File Description
src/decimo/errors.mojo Makes message and function required fields/args and updates formatting accordingly.
src/decimo/toml/parser.mojo Uses structured ValueError(message, function) for an inline-table duplicate-key error.
src/decimo/str.mojo Adds function="parse_numeric_string()" to all ValueError construction sites in numeric string parsing.
src/decimo/decimal128/exponential.mojo Adds required message to DecimoError wrappers in power().
src/decimo/decimal128/decimal128.mojo Uses structured ValueError(message, function) for from_components scale validation and adds function to other ValueErrors.
src/decimo/biguint/biguint.mojo Adds required message to DecimoError wrappers.
src/decimo/biguint/arithmetics.mojo Adds required message to DecimoError wrappers.
src/decimo/bigint10/bigint10.mojo Adds required message to DecimoError wrappers.
src/decimo/bigint10/arithmetics.mojo Adds required message to DecimoError wrappers.
src/decimo/bigint/bigint.mojo Adds required message to DecimoError wrappers.
src/decimo/bigfloat/bigfloat.mojo Adds required function / message to DecimoError sites (MPFR availability/allocation failures).

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

@forfudan forfudan merged commit 78b0c9c into dev Apr 9, 2026
15 checks passed
@forfudan forfudan deleted the error branch April 9, 2026 17:55
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