Skip to content

fix(site): show error on template upload failure #15558

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

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Nov 18, 2024

Closes #15441.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ethanndickson ethanndickson marked this pull request as ready for review November 18, 2024 10:51
onUpload: async (file: File) => {
try {
await uploadFileMutation.mutateAsync(file);
} catch (error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with this query library, but what I found is that even though you can set onError, an exception returned from mutateAsync isn't caught unless you explicitly catch it. So, If I displayed the error as part of onError in useMutation, I'd still need to wrap mutateAsync in a try block, with an empty catch, which seems pointless.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did it correctly. We usually use mutateAsync to keep the error handling close to where the mutation is called.

@ethanndickson ethanndickson force-pushed the ethan/template-upload-fail branch from 3650ef1 to a7781d0 Compare November 18, 2024 10:55
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test 👍

@ethanndickson ethanndickson merged commit a35c01d into main Nov 22, 2024
28 checks passed
@ethanndickson ethanndickson deleted the ethan/template-upload-fail branch November 22, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Web UI provides no feedback for a failed template upload
2 participants