From 541f9b67ac2bb62c36917285f1e1b6dc6df02aa1 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 4 Jun 2019 15:06:47 +0200 Subject: [PATCH] Probably improve error handling in strands --- src/danog/MadelineProto/API.php | 2 ++ src/danog/MadelineProto/Tools.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index 6538f48f..1f3bc846 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -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(); } diff --git a/src/danog/MadelineProto/Tools.php b/src/danog/MadelineProto/Tools.php index 36a7ff1f..8dce1997 100644 --- a/src/danog/MadelineProto/Tools.php +++ b/src/danog/MadelineProto/Tools.php @@ -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)