From 231bc3fc8d1902bb19b6fce39ffd72cce4b4f2c3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 12 Jun 2021 20:26:01 +0100 Subject: Avoid direct use of runtime_error in MySQL stuff Adds proper exception which extends it and gets the MySQL error message. --- lib/input/mysqlRecordSet.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/input/mysqlRecordSet.cpp') 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 #include @@ -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(fieldDefs, "Fetch fields"); + const auto fieldDefs = verify(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(!mysql_stmt_bind_result(stmt.get(), fields.data()), "Store result error"); - verify(!mysql_stmt_store_result(stmt.get()), "Store result error"); + verify(!mysql_stmt_bind_result(stmt.get(), fields.data()), "Store result error", stmt->mysql); + verify(!mysql_stmt_store_result(stmt.get()), "Store result error", stmt->mysql); stmtres = {stmt.get(), mysql_stmt_free_result}; - verify(!mysql_stmt_fetch(stmt.get()), "Fetch"); + verify(!mysql_stmt_fetch(stmt.get()), "Fetch", stmt->mysql); } std::size_t -- cgit v1.2.3