pg: More verbose error traces

Partly because some errors currently appeared to come from within FU::PG
itself, which is useless, and partly because it's common to wrap
database access methods, while that's exactly the kind of operation
where you *really* want to know where the error originated from.

(Source: too much time wasted debugging VNDB errors)
This commit is contained in:
Yorhel 2025-02-07 10:59:27 +01:00
parent 96aee880ce
commit 7c8473533d
4 changed files with 46 additions and 27 deletions

8
FU.xs
View file

@ -15,10 +15,10 @@
#define FUPG_CONN_COOKIE \
if (c->cookie) croak("Invalid attempt to run a query on the top-level connection while a transaction object exists")
if (c->cookie) fu_confess("Invalid attempt to run a query on the top-level connection while a transaction object exists")
#define FUPG_ST_COOKIE \
if (st->cookie != st->conn->cookie) croak("Invalid cross-transaction operation on statement object")
if (st->cookie != st->conn->cookie) fu_confess("Invalid cross-transaction operation on statement object")
typedef fupg_conn *fupg_txn;
@ -37,14 +37,14 @@ fupg_st * FUPG_ST
INPUT
FUPG_CONN
if (sv_derived_from($arg, \"FU::PG::conn\")) $var = (fupg_conn *)SvIVX(SvRV($arg));
else croak(\"invalid connection object\");
else fu_confess(\"invalid connection object\");
FUPG_TXN
$var = fupg_get_transaction(aTHX_ $arg);
FUPG_ST
if (sv_derived_from($arg, \"FU::PG::st\")) $var = (fupg_st *)SvIVX(SvRV($arg));
else croak(\"invalid statement object\");
else fu_confess(\"invalid statement object\");
#"
EOT