|
| template absl::AnyInvocable< void() && > | WrapConsuming< void > (absl::AnyInvocable< void() && >, std::string_view) |
| | For a11::Schedule and a11::ScheduleCancelable: work run once and discarded.
|
| |
| template<typename Callable > |
| absl::Status | Attempt (Callable &&callable, std::string_view what) |
| | Runs callable, reporting anything it throws as a Status.
|
| |
| template<typename Result , typename... Args> |
| std::function< Result(Args...)> | Wrap (std::function< Result(Args...)> callable, std::string_view what) |
| | Wraps callable so that anything it throws becomes a failure.
|
| |
| template<typename Result , typename... Args> |
| absl::AnyInvocable< Result(Args...)> | WrapOnce (absl::AnyInvocable< Result(Args...)> callable, std::string_view what) |
| | Wrap for a move-only callable.
|
| |
| template<typename Result , typename... Args> |
| absl::AnyInvocable< Result(Args...) && > | WrapConsuming (absl::AnyInvocable< Result(Args...) && > callable, std::string_view what) |
| | Wrap for a callable that is consumed by its one invocation.
|
| |
template<typename Callable >
| absl::Status a11::exception_guard::Attempt |
( |
Callable && |
callable, |
|
|
std::string_view |
what |
|
) |
| |
Runs callable, reporting anything it throws as a Status.
For a template in a header, where the instantiating translation unit is both the one that supplies the callable and the one that decides whether exceptions exist. See the file comment: inside A11 this is a plain call, and it is not the tool for a callable stored by A11 and invoked later.
- Parameters
-
| callable | Anything invocable with no arguments and no return value. |
| what | How to name it in the error, e.g. "on_message". |
- Returns
- OK, or what the callable threw.
template<typename Result , typename... Args>
| std::function< Result(Args...)> a11::exception_guard::Wrap |
( |
std::function< Result(Args...)> |
callable, |
|
|
std::string_view |
what |
|
) |
| |
Wraps callable so that anything it throws becomes a failure.
What "a failure" means depends on the return type: an error absl::Status or absl::StatusOr, a failed a11::Future, and for a callable returning void a logged error and nothing else – which is all a caller of a void callback could have done with it anyway.
- Parameters
-
| callable | What the caller handed us. An empty callable is returned as is, so a caller's own emptiness check still sees what it expects. |
| what | How to name the callable in the error, e.g. "on_message". The message reads <what> raised: <e.what()>, or <what> raised a non-standard exception for something that is not a std::exception. |