summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAotrix <[email protected]>2025-03-27 02:48:28 +0100
committerAotrix <[email protected]>2025-03-27 02:48:28 +0100
commit31ab522fb80473676ff31f3434f4651a1a4ee1a3 (patch)
tree5c7affc9296b628d64382b37cabe449314637671 /src/main.cpp
parent4417e2a50e0ae34abf68039ecd03975b463bdb50 (diff)
added exception handler for transactions
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 27397f0..bf1d53d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -9,12 +9,19 @@ int main() {
"postgresql://aotrix@localhost:5432/hearthstonegameinfo"};
pqxx::work tx{cx};
- const unsigned int card_id = 217;
- std::string card =
- hs_handler.get_cards(std::format("/{}?locale=fr_FR", card_id));
- std::cout << card << std::endl;
- add_cards_to_database(card, tx);
-
- tx.commit();
+ try {
+ std::string cards = hs_handler.get_cards(
+ "/108499?locale=fr_FR&gameMode=constructed&pageSize=2");
+ std::cout << cards << std::endl;
+ add_cards_to_database(cards, tx);
+ tx.commit();
+ } catch (pqxx::sql_error const &e) {
+ std::cerr << "SQL error: " << e.what() << std::endl;
+ std::cerr << "Query was: " << e.query() << std::endl;
+ return 2;
+ } catch (std::exception const &e) {
+ std::cerr << "Error: " << e.what() << std::endl;
+ return 1;
+ }
return 0;
}