fix: failed DM error handling
This commit is contained in:
parent
e479156270
commit
608400d010
@ -214,8 +214,22 @@ export class NostrController extends EventEmitter {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (publishedRelays.length === 0)
|
if (publishedRelays.length === 0) {
|
||||||
throw new Error(`Couldn't publish to any relay`)
|
const failedPublishes: any[] = []
|
||||||
|
|
||||||
|
results.forEach((res, index) => {
|
||||||
|
if (res.status === 'rejected') {
|
||||||
|
failedPublishes.push(
|
||||||
|
{
|
||||||
|
relay: relays[index],
|
||||||
|
error: res.reason.message
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
throw failedPublishes
|
||||||
|
}
|
||||||
|
|
||||||
return publishedRelays
|
return publishedRelays
|
||||||
}
|
}
|
||||||
|
@ -157,9 +157,14 @@ export const sendDM = async (
|
|||||||
.then((relays) => {
|
.then((relays) => {
|
||||||
toast.success(`Encrypted DM sent on: ${relays.join('\n')}`)
|
toast.success(`Encrypted DM sent on: ${relays.join('\n')}`)
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((errResults) => {
|
||||||
console.log('err :>> ', err)
|
console.log('err :>> ', errResults)
|
||||||
toast.error(err.message || 'An error occurred while publishing DM')
|
toast.error('An error occurred while publishing DM')
|
||||||
|
|
||||||
|
errResults.forEach((errResult: any) => {
|
||||||
|
toast.error(`${errResult.relay} -- ${errResult.error}`)
|
||||||
|
})
|
||||||
|
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user