Skip to content

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

Merged
ethanndickson merged 1 commit into
mainfrom
ethan/template-upload-fail
Nov 22, 2024
Merged

fix(site): show error on template upload failure#15558
ethanndickson merged 1 commit into
mainfrom
ethan/template-upload-fail

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Nov 18, 2024

Copy link
Copy Markdown
Member

Closes #15441.

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@BrunoQuaresma BrunoQuaresma Nov 22, 2024

Copy link
Copy Markdown
Contributor

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