Close database upon errors.

This commit is contained in:
Nicolás A. Ortega Froysa 2024-10-12 10:48:35 +02:00
parent d2f30dcca7
commit c31ccdece2

View File

@ -118,6 +118,7 @@ int cmd_delete(int argc, char *argv[]) {
if(not db.recipe_exists(id)) { if(not db.recipe_exists(id)) {
std::cerr << "No recipe exists with ID " << id << "." << std::endl; std::cerr << "No recipe exists with ID " << id << "." << std::endl;
db.close();
return EXIT_FAILURE; return EXIT_FAILURE;
} else { } else {
recipe_ids.push_back(id); recipe_ids.push_back(id);
@ -139,6 +140,7 @@ int cmd_info(const int id) {
if(not db.recipe_exists(id)) { if(not db.recipe_exists(id)) {
std::cerr << "No recipe with ID '" << id << "'"; std::cerr << "No recipe with ID '" << id << "'";
db.close();
return EXIT_FAILURE; return EXIT_FAILURE;
} }