numojo.core.error¶
Error handling for Numojo library operations.
This module provides a simple, unified error system for the Numojo library. All errors use a single NumojoError type with different categories for better organization while keeping the implementation simple. This provides a better user experience by providing clear error message and suggestions for fixing the error.
Currently we have a few common error categories like - IndexError - ShapeError - BroadcastError - MemoryError - ValueError - ArithmeticError
We can expand this list in the future as needed.
Aliases¶
RED_COLOR¶
Value: "\1B[31m"
END_COLOR¶
Value: "\1B[0m"
Structs¶
NumojoError¶
Memory convention: memory_only
Implements: AnyType, ImplicitlyDestructible, Writable
Unified error type for all Numojo operations.
Args: category: Type of error (e.g., "ShapeError", "IndexError"). message: Main error description and suggestion. location: Optional context about where error occurred.
Fields¶
category(String)message(String)location(Optional[String])
Aliases¶
ErrorDict¶
Value: Dict(List("index", "shape", "broadcast", "memory", "value", "arithmetic", Tuple()), List("IndexError", "ShapeError", "BroadcastError", "MemoryError", "ValueError", "ArithmeticError", Tuple()), Tuple())
__del__is_trivial¶
Value: False
Methods¶
__init__¶
Overload 1¶
__init__(out self, category: StringLiteral[category.value], message: StringLiteral[message.value], location: StringLiteral[location.value])
static
Args:
category(StringLiteral)message(StringLiteral)location(StringLiteral)self(Self)[out]
Returns:
Self
Overload 2¶
__init__(out self, category: StringLiteral[category.value], message: String, location: Optional[String] = None)
static
Args:
category(StringLiteral)message(String)location(Optional)self(Self)[out]
Returns:
Self
write_to¶
Write error information to a writer.
Parameters:
W(Writer)
Args:
self(Self)writer(W)[mut]