Skip to content
class

LucidError

LucidError

Base class for every typed exception thrown by the Lucid engine.

Derives from std::exception so generic handlers (catch (const std::exception&)) still observe the formatted message via what. Concrete subclasses are expected to populate the inherited msg_ field after their member fields are initialised, allowing the formatted text to reference moved-from constructor arguments through member accessors.

Pybind11 maps this class to lucid._C.engine.LucidError, which is a Python subclass of RuntimeError. All derived exception classes are further re-exported as Python subclasses of LucidError by bind_errors.cpp.

See Also

ErrorBuilder : Fluent helper that throws typed subclasses with a consistent "op: msg [trace=...]" format.

Parameters

msgstd::string
Fully formatted human-readable message. Stored verbatim; no further prefix is applied.

Attributes

msg_std::string
Owning storage for the formatted what() payload. Protected so subclasses can overwrite it after their members are initialised.

Examples

```
throw LucidError("unexpected null tensor in saved-graph slot");
```

Constructors

1
ctor

LucidError

void LucidError(int msg)

Constructs the base exception with a pre-formatted message.

Parameters

msgstd::string
Final text returned by what. Move-stored into msg_.

Methods

2
fn

prefix_message

void prefix_message(const int & context)

Puts context in front of the message, for a layer that rethrows an error it caught (catch (LucidError& e) { e.prefix_message(...); throw; }) and knows what was being done when it was raised. The class is kept, so the Python side still raises the same exception.

fnconst

what

→const char*
const char * what()

Returns a pointer to the stored message.

Returns

const char*

Null-terminated string owned by this exception. Lifetime is tied to *this; do not retain beyond the catch site.

Notes

Allocation-free: the string was built at construction time.