Probably improve error handling in strands

This commit is contained in:
Daniil Gentili 2019-06-04 15:06:47 +02:00
parent 5b51d71257
commit 541f9b67ac
2 changed files with 4 additions and 1 deletions

View File

@ -167,6 +167,8 @@ class API extends APIFactory
$this->init();
}
$this->API->logger('Shutting down MadelineProto (normally or due to an exception, idk)');
$this->API->destructing = true;
$this->destructing = true;
$this->wait($this->serialize());
//restore_error_handler();
}

View File

@ -300,10 +300,11 @@ trait Tools
$logger->logger("Got the following exception within a forked strand$file, trying to rethrow");
if ($e->getMessage() === "Cannot get return value of a generator that hasn't returned") {
$logger->logger("Well you know, this might actually not be the actual exception, scroll up in the logs to see the actual exception");
if (!isset($this->destructing)) Promise\rethrow(new Failure($e));
} else {
$logger->logger($e);
Promise\rethrow(new Failure($e));
}
Promise\rethrow(new Failure($e));
}
public function after($a, $b)