mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 14:38:50 +00:00
refactor(db/startTransaction): include query and values in errors
This commit is contained in:
1 parent
20083c6831
commit
d17559ba39
1 file changed
+7
-6
@@ -7,13 +7,14 @@ import { PoolConnection } from 'mysql2/promise';
|
||||
async function runQuery(conn: PoolConnection | null, sql: string, values: CFXParameters) {
|
||||
[sql, values] = parseArguments(sql, values);
|
||||
|
||||
if (!conn)
|
||||
throw new Error(
|
||||
`Query: ${sql}\n${JSON.stringify(values)}\nConnection used by transaction timed out after 30 seconds.`
|
||||
);
|
||||
try {
|
||||
if (!conn) throw new Error(`Connection used by transaction timed out after 30 seconds.`);
|
||||
|
||||
const [rows] = await conn.query(sql, values);
|
||||
return rows;
|
||||
const [rows] = await conn.query(sql, values);
|
||||
return rows;
|
||||
} catch (err: any) {
|
||||
throw new Error(`Query: ${sql}\n${JSON.stringify(values)}\n${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const startTransaction = async (
|
||||
|
||||
Reference in new issue
Block a user