-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error handling in fetchDocById
helper
#867
Fix error handling in fetchDocById
helper
#867
Conversation
Visit the preview URL for this PR (updated for commit 1522135): https://roar-staging--pr867-ref-318-query-compos-t79uux7m.web.app (expires Thu, 17 Oct 2024 22:02:25 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 2631e9c58fd0104ecbfddd72a62245ddac467460 |
roar-dashboard-e2e Run #8171
Run Properties:
|
Project |
roar-dashboard-e2e
|
Run status |
Passed #8171
|
Run duration | 02m 01s |
Commit |
1522135dc8: Component Tests for PR 867 "Fix error handling in `fetchDocById` helper" from co...
|
Committer | Maximilian Oertel |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
17
|
try { | ||
const activationCode = await fetchDocById('activationCodes', studentCode, undefined, 'admin', true, true); | ||
|
||
if (activationCode.orgId) { | ||
state.students[outerIndex].orgName = `${_capitalize(activationCode.orgType)} - ${ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we guarantee that these properties of activationCode
i.e. activationCode.orgType
exist? Should we add fallbacks or optional chaining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add optional chaining here so that if activationCode.orgType
doesn't exist, an error is thrown and caught by the catch
block. There is definitely big room for improvement on the error handling, but, in my opinion, that should be done in a separate PR?
Co-authored-by: Kyle Montville <[email protected]>
Co-authored-by: Kyle Montville <[email protected]>
This reverts commit 4fa5c46.
…mposables-fetch-error
Proposed changes
This PR removes the
swallowErrors
parameter on thefetchByDocId
helper to, well, prevent errors from being swallowed. Doing so and allowing the helper to throw any errors, enables any TanStack query using this helper function to properly handle error cases and trigger automatic retries.As this parameter was only used in the
validateCode
method, this PR also slightly refactors that function to handle thrown errors.Types of changes
Checklist
Justification of missing checklist items
n/a
Further comments
n/a
Ref https://github.com/yeatmanlab/roar/issues/318