diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:26:01 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:26:01 +0100 |
commit | 231bc3fc8d1902bb19b6fce39ffd72cce4b4f2c3 (patch) | |
tree | e074ea9bf53400600831215822a848fe27bfac55 /lib/input/mysqlRecordSet.cpp | |
parent | Have verify return its expression, might be useful (diff) | |
download | mygrate-231bc3fc8d1902bb19b6fce39ffd72cce4b4f2c3.tar.bz2 mygrate-231bc3fc8d1902bb19b6fce39ffd72cce4b4f2c3.tar.xz mygrate-231bc3fc8d1902bb19b6fce39ffd72cce4b4f2c3.zip |
Avoid direct use of runtime_error in MySQL stuff
Adds proper exception which extends it and gets the MySQL error message.
Diffstat (limited to 'lib/input/mysqlRecordSet.cpp')
-rw-r--r-- | lib/input/mysqlRecordSet.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/input/mysqlRecordSet.cpp b/lib/input/mysqlRecordSet.cpp index 51be15f..22b7214 100644 --- a/lib/input/mysqlRecordSet.cpp +++ b/lib/input/mysqlRecordSet.cpp @@ -1,5 +1,6 @@ #include "mysqlRecordSet.h" #include "mysqlBindings.h" +#include "mysqlConn.h" #include "mysqlStmt.h" #include <cstdint> #include <dbTypes.h> @@ -61,18 +62,17 @@ namespace MyGrate::Input { case MYSQL_TYPE_SET: case MYSQL_TYPE_GEOMETRY:; } - throw std::runtime_error("Unsupported column type"); + throw std::logic_error("Unsupported column type"); }; ResPtr meta {mysql_stmt_result_metadata(stmt.get()), mysql_free_result}; - const auto fieldDefs = mysql_fetch_fields(meta.get()); - verify<std::runtime_error>(fieldDefs, "Fetch fields"); + const auto fieldDefs = verify<MySQLErr>(mysql_fetch_fields(meta.get()), "Fetch fields", stmt->mysql); for (std::size_t i = 0; i < fields.size(); i += 1) { extras[i] = getBind(fieldDefs[i], fields[i]); } - verify<std::runtime_error>(!mysql_stmt_bind_result(stmt.get(), fields.data()), "Store result error"); - verify<std::runtime_error>(!mysql_stmt_store_result(stmt.get()), "Store result error"); + verify<MySQLErr>(!mysql_stmt_bind_result(stmt.get(), fields.data()), "Store result error", stmt->mysql); + verify<MySQLErr>(!mysql_stmt_store_result(stmt.get()), "Store result error", stmt->mysql); stmtres = {stmt.get(), mysql_stmt_free_result}; - verify<std::runtime_error>(!mysql_stmt_fetch(stmt.get()), "Fetch"); + verify<MySQLErr>(!mysql_stmt_fetch(stmt.get()), "Fetch", stmt->mysql); } std::size_t |