fix: show file upload errors

This commit is contained in:
Ramires Viana
2025-08-01 13:44:38 -03:00
committed by GitHub
parent af9b42549f
commit 06e8713fa5
3 changed files with 18 additions and 10 deletions

View File

@@ -55,12 +55,22 @@ export async function upload(
return true;
},
onError: function (error) {
onError: function (error: Error | tus.DetailedError) {
if (CURRENT_UPLOAD_LIST[filePath].interval) {
clearInterval(CURRENT_UPLOAD_LIST[filePath].interval);
}
delete CURRENT_UPLOAD_LIST[filePath];
reject(new Error(`Upload failed: ${error.message}`));
const message =
error instanceof tus.DetailedError
? error.originalResponse === null
? "000 No connection"
: error.originalResponse.getBody()
: "Upload failed";
console.error(error);
reject(new Error(message));
},
onProgress: function (bytesUploaded) {
const fileData = CURRENT_UPLOAD_LIST[filePath];