Skip to content

Fix error propagation in handleUpload function #41

@coderabbitai

Description

@coderabbitai

Description

The handleUpload function in next-ts/src/lib/common/helper-methods.ts (lines 49-84) currently swallows errors in its catch block, preventing callers from detecting upload failures. This causes the FileUpload component to show a "done" state even when uploads fail.

Location

  • File: next-ts/src/lib/common/helper-methods.ts
  • Lines: 49-84
  • Function: handleUpload

Problem

The catch block on line 80 logs the error and shows a toast message but never re-throws, causing callers like FileUpload/index.tsx to treat failed uploads as successful.

Proposed Solution

Update the catch block to propagate the failure by either:

  1. Re-throwing the caught error (throw error;)
  2. Returning Upload.LIST_IGNORE on error

Keep the existing logging and toast notifications but ensure the error is not swallowed.

Example Fix

} catch (error) {
  console.error(error);
  message.error("Upload failed");
  throw error; // Add this line
}

Context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions