Class VisitErrorContext#
Defined in File visit_error_context.h
Inheritance Relationships#
Base Type#
public tvm::ffi::ObjectRef(Class ObjectRef)
Class Documentation#
-
class VisitErrorContext : public tvm::ffi::ObjectRef#
Typed payload attached to Error::extra_context to support visit-context-aware error reporting.
The VisitErrorContext captures the reverse_visit_pattern — the chain of nodes visited before an error was thrown — so callers can translate it via FindAccessPaths into a structured access path for richer error messages.
Typical usage:
A recursive visit is instrumented with TVM_FFI_VISIT_BEGIN / _END(node). The deepest detection point throws via TVM_FFI_VISIT_THROW(kind, node), which seeds the context with the throw site; enclosing BEGIN/END pairs append parent nodes on rethrow.
The root catch handler retrieves the context via TryGetFromError(err), then resolves the chain into one or more reflection::AccessPath instances via FindAccessPaths(root, ctx).
The caller uses the AccessPath to enrich the error message with structured position info (e.g., “.body[2].cond.lhs”).
Public Static Functions
-
static inline Optional<VisitErrorContext> TryGetFromError(const Error &err)#
Get the VisitErrorContext attached to err’s extra_context.
- Parameters:
err – The error to inspect.
- Returns:
The attached VisitErrorContext, or NullOpt if absent.
-
static Array<reflection::AccessPath> FindAccessPaths(const ObjectRef &root, const VisitErrorContext &visit_context, bool allow_prefix_match = false)#
Find all access paths that match the pattern specified in the VisitErrorContext.
- Parameters:
root – The root ObjectRef to search from.
visit_context – The VisitErrorContext to match against.
allow_prefix_match – If true, also report paths where only a prefix of the pattern was matched (i.e., the algorithm descended through some matched records but could not find further matches before reaching a leaf). Default false — only full pattern matches are reported.
- Returns:
Array of matched access paths.