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/mysqlStmt.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/input/mysqlStmt.cpp') diff --git a/lib/input/mysqlStmt.cpp b/lib/input/mysqlStmt.cpp index 08d1303..d3ba9ef 100644 --- a/lib/input/mysqlStmt.cpp +++ b/lib/input/mysqlStmt.cpp @@ -1,5 +1,6 @@ #include "mysqlStmt.h" #include "mysqlBindings.h" +#include "mysqlConn.h" #include "mysqlRecordSet.h" #include #include @@ -10,15 +11,15 @@ namespace MyGrate::Input { MySQLPrepStmt::MySQLPrepStmt(const char * const q, MYSQL * c) : stmt {mysql_stmt_init(c), &mysql_stmt_close} { - verify(!mysql_stmt_prepare(stmt.get(), q, strlen(q)), q); + verify(!mysql_stmt_prepare(stmt.get(), q, strlen(q)), q, c); } void MySQLPrepStmt::execute(const std::initializer_list & vs) { Bindings b {vs}; - verify(!mysql_stmt_bind_param(stmt.get(), b.binds.data()), "Param count mismatch"); - verify(!mysql_stmt_execute(stmt.get()), "Prepared statement execute"); + verify(!mysql_stmt_bind_param(stmt.get(), b.binds.data()), "Param count mismatch"); + verify(!mysql_stmt_execute(stmt.get()), "Prepared statement execute", stmt->mysql); } std::size_t -- cgit v1.2.3