diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:54:28 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-06-12 20:54:28 +0100 |
commit | afd243cc87827c94f0cea73748ffc5c1fdf1880a (patch) | |
tree | ad3f9c39902a78026b24d9a32e8baf6ff2858281 /lib/output/pq/pqStmt.cpp | |
parent | Create a basic MySQL testing database class (diff) | |
download | mygrate-afd243cc87827c94f0cea73748ffc5c1fdf1880a.tar.bz2 mygrate-afd243cc87827c94f0cea73748ffc5c1fdf1880a.tar.xz mygrate-afd243cc87827c94f0cea73748ffc5c1fdf1880a.zip |
Avoid direct use of runtime_error in PostgreSQL stuff
Adds proper exception which extends it and gets the PostgreSQL error
message.
Diffstat (limited to 'lib/output/pq/pqStmt.cpp')
-rw-r--r-- | lib/output/pq/pqStmt.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/output/pq/pqStmt.cpp b/lib/output/pq/pqStmt.cpp index 078c239..dc258b6 100644 --- a/lib/output/pq/pqStmt.cpp +++ b/lib/output/pq/pqStmt.cpp @@ -24,8 +24,8 @@ namespace MyGrate::Output::Pq { Bindings b {vs}; res = {PQexecPrepared(conn, name.c_str(), (int)vs.size(), b.values.data(), b.lengths.data(), nullptr, 0), &PQclear}; - verify<std::runtime_error>( - PQresultStatus(res.get()) == PGRES_COMMAND_OK || PQresultStatus(res.get()) == PGRES_TUPLES_OK, name); + verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK || PQresultStatus(res.get()) == PGRES_TUPLES_OK, + name, conn); } std::size_t @@ -48,7 +48,7 @@ namespace MyGrate::Output::Pq { } auto nam {scprintf<"pst%0x">(c->stmts.size())}; ResPtr res {PQprepare(c->conn.get(), nam.c_str(), q, (int)n, nullptr), PQclear}; - verify<std::runtime_error>(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q); + verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q, c->conn.get()); return c->stmts.emplace(q, std::move(nam)).first->second; } } |