... since it's all just a test - added a try catch on db connection

This commit is contained in:
Blue 2023-12-07 17:47:15 -03:00
parent 03f38387e2
commit 89b80f0656
Signed by: blue
GPG Key ID: 9B203B252A63EE38

View File

@ -14,7 +14,13 @@ Server::Server():
db->setCredentials("pica", "pica");
db->setDatabase("pica");
try {
db->connect("/run/mysqld/mysqld.sock");
std::cout << "Successfully connected to the database" << std::endl;
} catch (const std::runtime_error& e) {
std::cerr << "Couldn't connect to the database: " << e.what() << std::endl;
}
router.addRoute("info", Server::info);
router.addRoute("env", Server::printEnvironment);