Handle error property in NWC response (#2343)

This commit is contained in:
ekzyis 2025-07-27 21:12:49 +02:00 committed by GitHub
parent a827dc6fde
commit cf5ac8272d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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