tus: Get more information from publish errors

This commit is contained in:
infinite-persistence 2022-01-06 15:29:17 +08:00
parent 555bde87f8
commit 01459d906a
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 14 additions and 3 deletions

View file

@ -281,7 +281,7 @@ export const doPublishDesktop = (filePath: string, preview?: boolean) => (dispat
actions.push({
type: ACTIONS.PUBLISH_FAIL,
});
actions.push(doError(error.message));
actions.push(doError({ message: error.message, cause: error.cause }));
dispatch(batchActions(...actions));
};
@ -351,7 +351,7 @@ export const doPublishResume = (publishPayload: any) => (dispatch: Dispatch, get
actions.push({
type: ACTIONS.PUBLISH_FAIL,
});
actions.push(doError(error.message));
actions.push(doError({ message: error.message, cause: error.cause }));
dispatch(batchActions(...actions));
};

View file

@ -84,7 +84,18 @@ export function makeResumableUploadRequest(
reject(new Error(`${status}: concurrent upload detected. Uploading the same file from multiple tabs or windows is not allowed.`));
} else {
window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' }));
reject(new Error(err));
reject(
// $FlowFixMe - flow's contructor for Error is incorrect.
new Error(err, {
cause: {
url: uploader.url,
...(uploader._fingerprint ? { fingerprint: uploader._fingerprint } : {}),
...(uploader._retryAttempt ? { retryAttempt: uploader._retryAttempt } : {}),
...(uploader._retryTimeout ? { retryTimeout: uploader._retryTimeout } : {}),
...(uploader._offsetBeforeRetry ? { offsetBeforeRetry: uploader._offsetBeforeRetry } : {}),
},
})
);
}
},
onProgress: (bytesUploaded, bytesTotal) => {