diff --git a/Source/Shared/arcana/threading/task.h b/Source/Shared/arcana/threading/task.h index 8deed68..3525e7a 100644 --- a/Source/Shared/arcana/threading/task.h +++ b/Source/Shared/arcana/threading/task.h @@ -119,6 +119,18 @@ namespace arcana return factory.to_return; } + template + void handle_unexpected(CallableT&& handler, cancellation& token) + { + this->then(inline_scheduler, token, [handler = std::forward(handler)](const expected& e) + { + if (e.has_error()) + { + handler(e.error()); + } + }); + } + private: explicit task(payload_ptr payload) : m_payload{ std::move(payload) }