interface ErrorTrace
e.trace() on a value of an @error type, and r.trace() on a union that holds one (§6.5, D-3960): the frames of the ?
operators this very value crossed, innermost first. The trace is stored in the value (a hidden field), so it survives
copies, moves, storage, tasks and channels. The method is provided by the compiler (Sema::lookupMethod).
Example:
@error data NotFound { what: str }
fn find(k: str) -> i64 | NotFound {
fail NotFound{ what: k }
}
fn lookup(k: str) -> i64 | NotFound {
let v = find(k)?
v
}
fn main() io {
match lookup("x") {
NotFound e => print("{e.trace().len() >= 1}")
_ => print("found")
}
}Output
true
pub(api) interface ErrorTraceSince. 1.0.0-beta
Methods
trace | () -> List<TraceFrame>The frames of the ? |
Defined in: std/core/types.oxl:925