Skip to content
class

ErrorContextGuard

ErrorContextGuard

RAII wrapper that pushes an op name on construction and pops it on destruction.

Preferred over the manual ErrorContext::push / ErrorContext::pop pair in any scope that may throw — the destructor guarantees the stack is balanced even when an exception propagates through. Move and copy are deleted to forbid transferring ownership of a stack frame between scopes, which would break the LIFO invariant.

Parameters

op_namestd::string
Identifier pushed onto the thread's ErrorContext stack on construction. The corresponding pop is performed by the destructor.

Examples

```
{
    ErrorContextGuard guard("conv2d");
    // ... any throw inside this scope is tagged "[trace=conv2d]" ...
}
```

Constructors

1
ctor

ErrorContextGuard

void ErrorContextGuard(int op_name)

Pushes op_name onto the thread's ErrorContext stack.

Parameters

op_namestd::string
Identifier for the in-flight op; moved into the stack.

Destructor

1

Operators

1
op

operator=

ErrorContextGuard & operator=(const ErrorContextGuard &)