Skip to content

Commit

Permalink
[promises] Generate a better error message for a common mistake (grpc…
Browse files Browse the repository at this point in the history
…#35191)

Closes grpc#35191

COPYBARA_INTEGRATE_REVIEW=grpc#35191 from ctiller:cg-promise-like-fix 0683ffe
PiperOrigin-RevId: 587026178
  • Loading branch information
ctiller authored and copybara-github committed Dec 1, 2023
1 parent 6e18346 commit e481f6a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/lib/promise/detail/promise_like.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class PromiseLike {
private:
GPR_NO_UNIQUE_ADDRESS F f_;

static_assert(!std::is_void<typename std::result_of<F()>::type>::value,
"PromiseLike cannot be used with a function that returns void "
"- return Empty{} instead");

public:
// NOLINTNEXTLINE - internal detail that drastically simplifies calling code.
PromiseLike(F&& f) : f_(std::forward<F>(f)) {}
Expand Down

0 comments on commit e481f6a

Please sign in to comment.