better message on failed intiation of protocol

This commit is contained in:
keyan 2022-01-24 12:36:08 -06:00
parent e37475f927
commit a9844f0c38
1 changed files with 8 additions and 1 deletions

View File

@ -192,7 +192,14 @@ export default {
createWithdrawl: createWithdrawal,
sendToLnAddr: async (parent, { addr, amount, maxFee }, { me, models, lnd }) => {
const [name, domain] = addr.split('@')
const res1 = await (await fetch(`https://${domain}/.well-known/lnurlp/${name}`)).json()
let req
try {
req = await fetch(`https://${domain}/.well-known/lnurlp/${name}`)
} catch (e) {
throw new Error(`error initiating protocol with https://${domain}`)
}
const res1 = await req.json()
if (res1.status === 'ERROR') {
throw new Error(res1.reason)
}