Compare commits

..

4 Commits

Author SHA1 Message Date
b
33ed372236 Merge pull request 'fix: failed DM error handling' (#19) from issue16 into main
All checks were successful
Release / build_and_release (push) Successful in 1m6s
Reviewed-on: https://git.sigit.io/sig/it/pulls/19
Reviewed-by: s <sabir@4gl.io>
2024-05-14 15:37:40 +00:00
Davinci
f6a2f4aa48 chore: error message 2024-05-14 17:20:19 +02:00
b
7c2b8dc53e Merge branch 'main' into issue16 2024-05-14 15:09:09 +00:00
Davinci
608400d010 fix: failed DM error handling 2024-05-13 13:11:52 +02:00
2 changed files with 24 additions and 5 deletions

View File

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

View File

@ -161,9 +161,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(`Publishing to ${errResult.relay} caused the following error: ${errResult.error}`)
})
return null return null
}) })
} }