Mojo struct
Error
struct Error
This type represents an Error.
Implemented traits
AnyType,
Copyable,
ImplicitlyDestructible,
Movable,
Representable,
Stringable,
Writable
comptime members
__copyinit__is_trivial
comptime __copyinit__is_trivial = False
__del__is_trivial
comptime __del__is_trivial = False
__moveinit__is_trivial
comptime __moveinit__is_trivial = _all_trivial_moveinit[_NoneType, StackTrace]()
Methods
__init__
@implicit
__init__(out self, var value: String, *, depth: Int = -1)
Construct an Error object with a given String.
Args:
@implicit
__init__(out self, value: StringLiteral[value])
Construct an Error object with a given string literal.
Args:
- value (
StringLiteral): The error message.
@implicit
__init__(out self, var error: T)
Construct an Error from a Writable argument.
Args:
- error (
T): The error to store.
__init__[*Ts: Writable](out self, *args: *Ts)
Construct an Error by concatenating a sequence of Writable arguments.
Parameters:
- *Ts (
Writable): The types of the arguments to format. Each type must be satisfyWritable.
Args:
- *args (
*Ts): A sequence of Writable arguments.
__str__
__str__(self) -> String
Converts the Error to string representation.
Returns:
String: A String of the error message.
write_to
write_to(self, mut writer: T)
Formats this error to the provided Writer.
Args:
- writer (
T): The object to write to.
__repr__
__repr__(self) -> String
Converts the Error to printable representation.
Returns:
String: A printable representation of the error message.
get_stack_trace
get_stack_trace(self) -> Optional[String]
Returns the stack trace of the error, if available.
Returns:
Optional: An Optional[String] containing the stack trace if one was
collected, or None if stack trace collection was disabled
or unavailable.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!