Skip to content

Commit

Permalink
Merge pull request #33 from gov4git/error
Browse files Browse the repository at this point in the history
Error
  • Loading branch information
dworthen authored Oct 31, 2023
2 parents eea0163 + 421c403 commit 656aafc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-pianos-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gov4git-desktop-app': patch
---

Update gov4git dependency to v1.1.13
8 changes: 8 additions & 0 deletions .changeset/thin-numbers-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'gov4git-desktop-app': patch
---

Improve error handling

- Report voting errors within the vote window
- Scroll to top of the page when error logs are presented
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"dependencies": {
"@fluentui/react-components": "^9.22.0",
"@fluentui/react-icons": "^2.0.204",
"@gov4git/js-client": "1.1.12",
"@gov4git/js-client": "1.1.13",
"@vscode/codicons": "^0.0.33",
"better-sqlite3": "^9.0.0",
"drizzle-orm": "^0.28.6",
Expand All @@ -118,4 +118,4 @@
"type": "git",
"url": "https://github.com/gov4git/desktop-application.git"
}
}
}
9 changes: 8 additions & 1 deletion src/renderer/src/components/IssueBallot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,28 @@ export const IssueBallot: FC<IssueBallotProps> = function IssueBallot({
choice: ballot.choices[0] ?? '',
strength: `${voteStrengthInCredits}`,
})
.then(() => {
eventBus.emit('voted', { ballotId: ballot.identifier })
})
.catch(async (ex) => {
if (
ex != null &&
ex.message != null &&
typeof ex.message === 'string' &&
(ex.message as string).toLowerCase().endsWith('ballot is closed')
) {
setFetchingNewBallot(false)
setVoteError(
'Sorry, this ballot is closed to voting. Please refresh the page to get the latest list of ballots.',
)
} else {
await catchError(`Failed to cast vote. ${ex}`)
setFetchingNewBallot(false)
setVoteError(
`There was an error voting. Please view the full logs at the top of the page.`,
)
}
})
eventBus.emit('voted', { ballotId: ballot.identifier })
}
}
void run()
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/hooks/useCatchError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export function useCatchError() {
setConfigErrors(configErrors)
navigate(routes.settings.path)
} else {
window.scrollTo(0, 0)
setErrorMessage(error)
}
} catch (ex) {
window.scrollTo(0, 0)
setErrorMessage(error)
}
},
Expand Down

0 comments on commit 656aafc

Please sign in to comment.