async.Future.markHandled
Acknowledges a faulted Future so it is not reported as unhandled; does not consume the value (getValue still reads it)
Notes
Does not consume the value: getValue still reads it afterward, and getState still reports "faulted". This is the explicit counterpart to getValue's peek, for code that inspects a fault and takes responsibility for it without ever calling await on the future.
A no-op on a future that is already fulfilled. Calling it before the future settles pre-acknowledges: whatever fault lands on it later is still not reported. Calling it more than once is harmless.
Example
from "async" import Future
// Acknowledge after the fault: value and state are unchanged.
let f = Future()
f.reject("boom")
f.markHandled()
println("f.getState() / f.getValue() =", $"{f.getState()} / {f.getValue()}")
// Pre-acknowledge before the fault: still no report when it lands.
let g = Future()
g.markHandled()
g.reject("later")
println("g.getState() / g.getValue() =", $"{g.getState()} / {g.getValue()}")Output:
f.getState() / f.getValue() = faulted / boom
g.getState() / g.getValue() = faulted / laterSee also
getValue | Returns the settled value (fulfilled or fault value); throws while pending. A pure peek: reading a fault does not acknowledge it (see markHandled) |
reject | Faults a pending Future with value (default null); ignored if already settled |
getState | Returns the lifecycle state: 'pending', 'fulfilled' or 'faulted' |
| Future | class index |