Handle error property in NWC response (#2343)
This commit is contained in:
parent
a827dc6fde
commit
cf5ac8272d
@ -45,7 +45,9 @@ export async function nwcTryRun (fun, { url }, { signal }) {
|
|||||||
const nostr = new Nostr()
|
const nostr = new Nostr()
|
||||||
try {
|
try {
|
||||||
const nwc = await getNwc(nostr, url, { signal })
|
const nwc = await getNwc(nostr, url, { signal })
|
||||||
return await fun(nwc)
|
const res = await fun(nwc)
|
||||||
|
if (res.error) throw new Error(res.error)
|
||||||
|
return res
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.error) throw new Error(e.error.message || e.error.code)
|
if (e.error) throw new Error(e.error.message || e.error.code)
|
||||||
throw e
|
throw e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user