Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/decimo/errors.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,28 @@ comptime _CLR_FUNC_NAME = _YELLOW # Function name
comptime _CLR_MSG_TEXT = _BOLD # Error message text
comptime _CLR_CHAIN_MSG = _DIM # Chained error separator message

comptime OverflowError = DecimoError[error_type="OverflowError"]
comptime DecimoError = BaseError[error_type="DecimoError"]
"""Type for general erros in Decimo."""

comptime OverflowError = BaseError[error_type="OverflowError"]
"""Type for overflow errors in Decimo."""

comptime IndexError = DecimoError[error_type="IndexError"]
comptime IndexError = BaseError[error_type="IndexError"]
"""Type for index errors in Decimo."""

comptime KeyError = DecimoError[error_type="KeyError"]
comptime KeyError = BaseError[error_type="KeyError"]
"""Type for key errors in Decimo."""

comptime ValueError = DecimoError[error_type="ValueError"]
comptime ValueError = BaseError[error_type="ValueError"]
"""Type for value errors in Decimo."""

comptime ZeroDivisionError = DecimoError[error_type="ZeroDivisionError"]
comptime ZeroDivisionError = BaseError[error_type="ZeroDivisionError"]
"""Type for divided-by-zero errors in Decimo."""

comptime ConversionError = DecimoError[error_type="ConversionError"]
comptime ConversionError = BaseError[error_type="ConversionError"]
"""Type for conversion errors in Decimo."""

comptime RuntimeError = DecimoError[error_type="RuntimeError"]
comptime RuntimeError = BaseError[error_type="RuntimeError"]
"""Type for runtime infrastructure errors in Decimo (e.g., resource allocation
failures, missing native libraries)."""

Expand Down Expand Up @@ -133,7 +136,7 @@ def _shorten_path_implementation(full_path: String) -> String:
return full_path


struct DecimoError[error_type: StringLiteral = "DecimoError"](Writable):
struct BaseError[error_type: StringLiteral = "BaseError"](Writable):
"""Base type for all Decimo errors.

The error message format mimics Python's traceback:
Expand Down Expand Up @@ -172,7 +175,7 @@ struct DecimoError[error_type: StringLiteral = "DecimoError"](Writable):
function: String,
previous_error: Optional[Error] = None,
):
"""Creates a new `DecimoError` with auto-captured file and line.
"""Creates a new `BaseError` with auto-captured file and line.

File name and line number are automatically captured from the call site.

Expand Down Expand Up @@ -213,7 +216,7 @@ struct DecimoError[error_type: StringLiteral = "DecimoError"](Writable):

Traceback (most recent call last):
File "./src/decimo/bigint/bigint.mojo", line 20, in outer_function
DecimoError: outer error message
BaseError: outer error message
```

Parameters:
Expand Down
Loading