fix(http): reset pdo connection if broken
This commit is contained in:
parent
bb95ec536b
commit
df24011d8b
11
app/http.php
11
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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue