baml.errors.Context

The temporal context of a thrown error: the error value itself, where it was thrown, and the error it superseded while the scope was unwinding (its `cause`), if any. Bound by the second parameter of a `catch (e, ctx)` handler.

Reference version

Signature

class baml.errors.Context

The temporal context of a thrown error: the error value itself, where it was thrown, and the error it superseded while the scope was unwinding (its cause), if any. Bound by the second parameter of a catch (e, ctx) handler.

The chain runs newest → oldest through cause; root_cause walks to the original failure at the tail, and to_string renders the whole chain Python-style ("During handling of the above error, another error occurred").

Source:<builtin>/baml/ns_errors/error_context.bamlbytes 482–1137

Fields

error

unknown

cause

baml.errors.Context | null

Instance methods

function

_to_string_impl

(self) -> string throws never
function

root_cause

(self) -> baml.errors.Context throws never

The original error at the tail of the cause chain — walks cause to the deepest link. Returns self when nothing was superseded.

Implementations

baml.Concrete for T

Source:<builtin>/baml/core.bamlbytes 763–795

baml.ToString for baml.errors.Context

Instance methods

function

to_string

(self) -> string throws never

Source:<builtin>/baml/ns_errors/error_context.bamlbytes 896–1031