From 46f6879108fc3a3064d246b8ca6b9e183e006e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Thu, 7 Apr 2022 21:48:24 +0100 Subject: [PATCH] feat: sendCoins error handling --- lib/plugins/wallet/galoy/galoy.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/plugins/wallet/galoy/galoy.js b/lib/plugins/wallet/galoy/galoy.js index 1147cc85..a3c1c39c 100644 --- a/lib/plugins/wallet/galoy/galoy.js +++ b/lib/plugins/wallet/galoy/galoy.js @@ -171,7 +171,14 @@ function sendCoins (account, tx, settings, operatorId) { return sendFundsOnChain(wallet.id, toAddress, cryptoAtoms, account.authToken) }) .then(result => { - return result + switch (result.status) { + case 'ALREADY_PAID': + throw new Error('Transaction already exists!') + case 'FAILURE': + throw new Error('Transaction failed!') + default: + return '' + } }) .catch(err => { throw err