From f484ee67a7bd1be75aea6ea82a2e473e3e16b108 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 30 Jun 2024 16:12:30 +0200 Subject: [PATCH] Set up a loop error handler --- bootstrap.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bootstrap.php b/bootstrap.php index 0705a7d..3c92ba2 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -1,5 +1,8 @@ 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); +}); \ No newline at end of file