fix: expose more detailed error messages
This commit is contained in:
parent
d37aa61501
commit
71791c9513
27 changed files with 330 additions and 153 deletions
|
|
@ -7,7 +7,6 @@ import { CheckIcon, Loader, PlusIcon } from 'lucide-react'
|
|||
import { Event } from 'nostr-tools'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { toast } from 'sonner'
|
||||
import Image from '../Image'
|
||||
|
||||
export default function EmojiPack({ event, className }: { event: Event; className?: string }) {
|
||||
|
|
@ -27,14 +26,8 @@ export default function EmojiPack({ event, className }: { event: Event; classNam
|
|||
if (isCollected) return
|
||||
|
||||
setUpdating(true)
|
||||
try {
|
||||
await addEmojiPack(event)
|
||||
toast.success(t('Emoji pack added'))
|
||||
} catch (error) {
|
||||
toast.error(t('Add emoji pack failed') + ': ' + (error as Error).message)
|
||||
} finally {
|
||||
setUpdating(false)
|
||||
}
|
||||
await addEmojiPack(event)
|
||||
setUpdating(false)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -44,14 +37,8 @@ export default function EmojiPack({ event, className }: { event: Event; classNam
|
|||
if (!isCollected) return
|
||||
|
||||
setUpdating(true)
|
||||
try {
|
||||
await removeEmojiPack(event)
|
||||
toast.success(t('Emoji pack removed'))
|
||||
} catch (error) {
|
||||
toast.error(t('Remove emoji pack failed') + ': ' + (error as Error).message)
|
||||
} finally {
|
||||
setUpdating(false)
|
||||
}
|
||||
await removeEmojiPack(event)
|
||||
setUpdating(false)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { POLL_TYPE } from '@/constants'
|
|||
import { useTranslatedEvent } from '@/hooks'
|
||||
import { useFetchPollResults } from '@/hooks/useFetchPollResults'
|
||||
import { createPollResponseDraftEvent } from '@/lib/draft-event'
|
||||
import { formatError } from '@/lib/error'
|
||||
import { getPollMetadataFromEvent } from '@/lib/event-metadata'
|
||||
import { cn, isPartiallyInViewport } from '@/lib/utils'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
|
|
@ -126,8 +127,10 @@ export default function Poll({ event, className }: { event: Event; className?: s
|
|||
setSelectedOptionIds([])
|
||||
pollResultsService.addPollResponse(event.id, pubkey, selectedOptionIds)
|
||||
} catch (error) {
|
||||
console.error('Failed to vote:', error)
|
||||
toast.error('Failed to vote: ' + (error as Error).message)
|
||||
const errors = formatError(error)
|
||||
errors.forEach((err) => {
|
||||
toast.error(`${t('Failed to vote')}: ${err}`, { duration: 10_000 })
|
||||
})
|
||||
} finally {
|
||||
setIsVoting(false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue