Skip to content

Commit 9c1b932

Browse files
author
lh01217311
committed
fix: add catch to uploadFiles to prevent unhandled rejection
1 parent 6ca0146 commit 9c1b932

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/AjaxUploader.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,21 @@ class AjaxUploader extends Component<UploadProps> {
179179
});
180180

181181
// Batch upload files
182-
Promise.all(postFiles).then(fileList => {
183-
const { onBatchStart } = this.props;
182+
Promise.all(postFiles)
183+
.then(fileList => {
184+
const { onBatchStart } = this.props;
184185

185-
onBatchStart?.(fileList.map(({ origin, parsedFile }) => ({ file: origin, parsedFile })));
186+
onBatchStart?.(fileList.map(({ origin, parsedFile }) => ({ file: origin, parsedFile })));
186187

187-
fileList
188-
.filter(file => file.parsedFile !== null)
189-
.forEach(file => {
190-
this.post(file);
191-
});
192-
});
188+
fileList
189+
.filter(file => file.parsedFile !== null)
190+
.forEach(file => {
191+
this.post(file);
192+
});
193+
})
194+
.catch(() => {
195+
// Error already handled in processFile, this catch is to prevent unhandled rejection
196+
});
193197
};
194198

195199
/**

0 commit comments

Comments
 (0)