From df24011d8b8366a193baf8d40f7bbd1465205f53 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 12 Jul 2021 12:04:00 +0200 Subject: [PATCH] fix(http): reset pdo connection if broken --- app/http.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index 6b216da802..1329814d9c 100644 --- a/app/http.php +++ b/app/http.php @@ -98,11 +98,20 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo $app->run($request, $response); } catch (\Throwable $th) { - Console::error('[Error] Type: '.get_class($th)); + $type = get_class($th); + + Console::error('[Error] Type: '.$type); Console::error('[Error] Message: '.$th->getMessage()); Console::error('[Error] File: '.$th->getFile()); Console::error('[Error] Line: '.$th->getLine()); + /** + * Reset Database connection if PDOException was thrown. + */ + if ($type === 'PDOException') { + $db = null; + } + if(App::isDevelopment()) { $swooleResponse->end('error: '.$th->getMessage()); }