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")
}
}Вывод
true
pub(api) interface ErrorTraceС версии. 1.0.0-beta
Методы
trace | () -> List<TraceFrame>The frames of the ? |
Определено в: std/core/types.oxl:925