Skip to content
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: Catch preflight errors on file upload #212

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion source/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,14 @@ export class Uploader<TEntityTypeMap extends Record<string, any>> {
/** Initiate upload. Promise is resolved once preflight is complete and upload started. */
async start() {
logger.debug("Upload starting", this.componentId);
await this.uploadPreflight();
try {
await this.uploadPreflight();
} catch (error) {
if (this.onError) {
this.onError(error as Error);
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably retain the previous behavior where start throw:ed if the preflight failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
return;
if (this.onError) {
this.onError(error as Error);
}
throw error;
image

When I throw an error like above instead of return, I receive this error message instead of notifyError. Is there any way to prevent this?

}
if (!this.uploadMetadata) {
throw new Error("Failed to get upload metadata");
}
Expand Down
Loading