Quirrel4.41.0

async.Future.markHandled

Method of Future, from module "async"
instance.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

examples/async/future/markHandled.nut
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 / later

See also

getValueReturns the settled value (fulfilled or fault value); throws while pending. A pure peek: reading a fault does not acknowledge it (see markHandled)
rejectFaults a pending Future with value (default null); ignored if already settled
getStateReturns the lifecycle state: 'pending', 'fulfilled' or 'faulted'
Futureclass index