exact error handling
This commit is contained in:
parent
47f37b06d8
commit
e8ad0b854c
1 changed files with 9 additions and 7 deletions
|
|
@ -921,6 +921,11 @@ const sendPayment = async (to, amount, memo, gun, user, SEA) => {
|
||||||
services: { lightning }
|
services: { lightning }
|
||||||
} = LightningServices
|
} = LightningServices
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {object} SendErr
|
||||||
|
* @prop {string} details
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Partial
|
* Partial
|
||||||
* https://api.lightning.community/#grpc-response-sendresponse-2
|
* https://api.lightning.community/#grpc-response-sendresponse-2
|
||||||
|
|
@ -929,17 +934,14 @@ const sendPayment = async (to, amount, memo, gun, user, SEA) => {
|
||||||
* @prop {any[]|null} payment_route
|
* @prop {any[]|null} payment_route
|
||||||
*/
|
*/
|
||||||
|
|
||||||
await new Promise((rej, resolve) => {
|
await new Promise((resolve, rej) => {
|
||||||
lightning.sendPaymentSync(
|
lightning.sendPaymentSync(
|
||||||
{
|
{
|
||||||
payment_request: decInvoice
|
payment_request: decInvoice
|
||||||
},
|
},
|
||||||
(/*** @type {any} */ err, /** @type {SendResponse} */ res) => {
|
(/** @type {SendErr=} */ err, /** @type {SendResponse} */ res) => {
|
||||||
console.log(`sendPaymentSync err: ${JSON.stringify(err)}`)
|
if (err) {
|
||||||
console.log(`sendPaymentSync res: ${JSON.stringify(res)}`)
|
rej(new Error(err.details))
|
||||||
|
|
||||||
if (err || typeof err === 'number') {
|
|
||||||
rej(new Error(`sendPaymentSync error: ${JSON.stringify(err)}`))
|
|
||||||
} else if (res) {
|
} else if (res) {
|
||||||
if (res.payment_error) {
|
if (res.payment_error) {
|
||||||
rej(
|
rej(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue