mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 19:51:11 +01:00
Intercept and rethrow exceptions during update handling
This commit is contained in:
parent
f139decef3
commit
bfea44e0df
@ -50,6 +50,13 @@ use function Amp\Future\awaitFirst;
|
||||
*/
|
||||
abstract class AsyncTools extends StrTools
|
||||
{
|
||||
/**
|
||||
* Rethrow exception into event loop.
|
||||
*/
|
||||
public static function rethrow(\Throwable $e): void
|
||||
{
|
||||
EventLoop::queue(fn () => throw $e);
|
||||
}
|
||||
/**
|
||||
* Synchronously wait for a Future|generator.
|
||||
*
|
||||
|
@ -21,6 +21,7 @@ declare(strict_types=1);
|
||||
namespace danog\MadelineProto\Loop\Update;
|
||||
|
||||
use danog\Loop\Loop;
|
||||
use danog\MadelineProto\AsyncTools;
|
||||
use danog\MadelineProto\Logger;
|
||||
use danog\MadelineProto\Loop\InternalLoop;
|
||||
use danog\MadelineProto\MTProto;
|
||||
@ -85,7 +86,11 @@ final class FeedLoop extends Loop
|
||||
$parsedUpdates = $this->parsedUpdates;
|
||||
$this->parsedUpdates = [];
|
||||
foreach ($parsedUpdates as $update) {
|
||||
$this->API->saveUpdate($update);
|
||||
try {
|
||||
$this->API->saveUpdate($update);
|
||||
} catch (\Throwable $e) {
|
||||
AsyncTools::rethrow($e);
|
||||
}
|
||||
}
|
||||
$parsedUpdates = null;
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ trait UpdateHandler
|
||||
throw $e;
|
||||
}
|
||||
} catch (RPCErrorException $e) {
|
||||
if ($e->rpc !== 'CHANNEL_PRIVATE') {
|
||||
if ($e->rpc !== 'CHANNEL_PRIVATE' && $e->rpc !== 'MSG_ID_INVALID') {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user