projects
/
m6w6
/
seekat
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
PHP8
[m6w6/seekat]
/
lib
/
API
/
Consumer.php
diff --git
a/lib/API/Consumer.php
b/lib/API/Consumer.php
index 926eb736e756f066d61d9b7db1b497dfa0b18a4e..3af614caa9355335c70278f36395f2f5449f8d17 100644
(file)
--- a/
lib/API/Consumer.php
+++ b/
lib/API/Consumer.php
@@
-2,15
+2,12
@@
namespace seekat\API;
namespace seekat\API;
+use Exception;
use Generator;
use Generator;
-use http\Client;
use seekat\API;
use seekat\API;
-use seekat\Exception\{
- InvalidArgumentException, UnexpectedValueException, function exception
-};
+use seekat\Exception\{function exception};
-final class Consumer
-{
+final class Consumer {
/**
* Loop
* @var callable
/**
* Loop
* @var callable
@@
-79,7
+76,6
@@
final class Consumer
*/
function __invoke(Generator $gen) {
$this->cancelled = false;
*/
function __invoke(Generator $gen) {
$this->cancelled = false;
-
foreach ($gen as $promise) {
if ($this->cancelled) {
break;
foreach ($gen as $promise) {
if ($this->cancelled) {
break;
@@
-87,15
+83,14
@@
final class Consumer
$this->give($promise, $gen);
}
$this->give($promise, $gen);
}
- #($this->loop)();
-
- if (!$this->cancelled) {
- $this->result = $gen->getReturn();
- }
- if (isset($this->result)) {
- ($this->resolve)($this->result);
- } else {
+ if ($this->cancelled) {
($this->reject)("Cancelled");
($this->reject)("Cancelled");
+ } else {
+ try {
+ $this->result = $gen->getReturn();
+ } catch (Exception $e) {
+ }
+ ($this->resolve)($this->result);
}
return $this->context->promise();
}
return $this->context->promise();