1
0
Fork 0
mirror of synced 2024-06-29 19:50:26 +12:00

Improve exception

This commit is contained in:
Bradley Schofield 2021-10-27 10:21:16 +01:00
parent aca61d1902
commit 91827930c0

View file

@ -46,14 +46,18 @@ App::get('/v1/health/db')
->action(function ($response, $utopia) {
/** @var Appwrite\Utopia\Response $response */
/** @var Utopia\App $utopia */
$db = $utopia->getResource('db'); /* @var $db PDO */
try {
$db = $utopia->getResource('db'); /* @var $db PDO */
// Run a small test to check the connection
$statement = $db->prepare("SELECT 1;");
$statement->closeCursor();
$statement->execute();
// Run a small test to check the connection
$statement = $db->prepare("SELECT 1;");
$statement->closeCursor();
$statement->execute();
} catch (Exception $_e) {
throw new Exception('Database is not available', 500);
}
return $response->json(['status' => 'OK']);
});