Skip to content

Commit

Permalink
Merge pull request #8106 from appwrite/fix-realtime-string-error-code
Browse files Browse the repository at this point in the history
Handle SQL error code 'HY000' in realtime
  • Loading branch information
abnegate committed May 9, 2024
2 parents 1ee1284 + e5f49b4 commit 86a822c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/realtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,16 +511,22 @@ function getCache(): Cache
} catch (Throwable $th) {
call_user_func($logError, $th, "initServer");

// Handle SQL error code is 'HY000'
$code = $th->getCode();
if (!is_int($code)) {
$code = 500;
}

$response = [
'type' => 'error',
'data' => [
'code' => $th->getCode(),
'code' => $code,
'message' => $th->getMessage()
]
];

$server->send([$connection], json_encode($response));
$server->close($connection, $th->getCode());
$server->close($connection, $code);

if (App::isDevelopment()) {
Console::error('[Error] Connection Error');
Expand Down

0 comments on commit 86a822c

Please sign in to comment.