From 2b4e5313679f0a26be2e1561900cb93076b30913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Wed, 2 Feb 2022 14:19:02 +0000 Subject: [PATCH] refactor: add transaction ID to stale errors --- lib/cash-in/cash-in-atomic.js | 2 +- lib/cash-out/cash-out-atomic.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cash-in/cash-in-atomic.js b/lib/cash-in/cash-in-atomic.js index 8a23360c..e3441a76 100644 --- a/lib/cash-in/cash-in-atomic.js +++ b/lib/cash-in/cash-in-atomic.js @@ -18,7 +18,7 @@ function atomic (machineTx, pi) { return t.oneOrNone(sql, [machineTx.id]) .then(row => { - if (row && row.tx_version >= machineTx.txVersion) throw new E.StaleTxError('Stale tx') + if (row && row.tx_version >= machineTx.txVersion) throw new E.StaleTxError({ txId: machineTx.id }) return t.any(sql2, [machineTx.id]) .then(billRows => { diff --git a/lib/cash-out/cash-out-atomic.js b/lib/cash-out/cash-out-atomic.js index e51710d5..c82f6f65 100644 --- a/lib/cash-out/cash-out-atomic.js +++ b/lib/cash-out/cash-out-atomic.js @@ -25,7 +25,7 @@ function atomic (tx, pi, fromClient) { .then(toObj) .then(oldTx => { const isStale = fromClient && oldTx && (oldTx.txVersion >= tx.txVersion) - if (isStale) throw new E.StaleTxError('Stale tx') + if (isStale) throw new E.StaleTxError({ txId: tx.id }) return preProcess(t, oldTx, tx, pi) .then(preProcessedTx => cashOutLow.upsert(t, oldTx, preProcessedTx))