mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-26 11:54:42 +01:00
Set up a loop error handler
This commit is contained in:
parent
781766f849
commit
f484ee67a7
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Amp\Future\UnhandledFutureError;
|
||||||
|
use Amp\SignalException;
|
||||||
|
use danog\MadelineProto\SecurityException;
|
||||||
use Revolt\EventLoop;
|
use Revolt\EventLoop;
|
||||||
use TelegramApiServer\Logger;
|
use TelegramApiServer\Logger;
|
||||||
use TelegramApiServer\Migrations\EnvUpgrade;
|
use TelegramApiServer\Migrations\EnvUpgrade;
|
||||||
@ -113,3 +116,16 @@ if (!function_exists('emergency')) {
|
|||||||
Logger::getInstance()->emergency($message, $context);
|
Logger::getInstance()->emergency($message, $context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventLoop::setErrorHandler(function (\Throwable $e) {
|
||||||
|
if ($e instanceof UnhandledFutureError) {
|
||||||
|
$e = $e->getPrevious();
|
||||||
|
}
|
||||||
|
if ($e instanceof SecurityException || $e instanceof SignalException) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
if (str_starts_with($e->getMessage(), 'Could not connect to DC ')) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
emergency((string) $e);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user