folly::coro::value_or_error

When awaited, returns a result<T> in a value or an error state, but never has_stopped() (aka OperationCancelled). If awaitable reports as "stopped", the awaiting coroutine will be promptly torn down, **without throwing**, and its parent will in turn receive a "stopped" completion.

Synopsis

Declared in <folly/coro/ValueOrError.h>

template<typename Awaitable>
/* implementation-defined */
value_or_error(Awaitable awaitable);

Description

BE CAREFUL -- This is co_nothrow semantics, but only for cancellation. -- if your coro requires async cleanup, such as awaiting an async scope or other background work, then you must use a safe async RAII pattern, such async_closure if applicable (or co_scope_exit, but beware of its lifetime risks).

Return Value

a result<T> in a value or error state, never stopped

Parameters

NameDescription
awaitablethe awaitable to run