diff --git a/lib/functions.php b/lib/functions.php index d704144a..b9523132 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -757,10 +757,12 @@ function coroutine(callable $func) { */ function resolve($generator) { if (!$generator instanceof \Generator) { - if (is_callable($generator)) { - $generator = call_user_func($generator); + if (!is_callable($generator)) { + throw new \InvalidArgumentException('Coroutine to resolve must be callable or instance of Generator'); } + $generator = call_user_func($generator); + if (!$generator instanceof \Generator) { throw new \LogicException('Callable passed to resolve() did not return an instance of Generator'); }