From 01459d906ad85175b9841fc8e67512fdf4ae0cbf Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Thu, 6 Jan 2022 15:29:17 +0800 Subject: [PATCH] tus: Get more information from publish errors --- ui/redux/actions/publish.js | 4 ++-- web/setup/publish-v2.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ui/redux/actions/publish.js b/ui/redux/actions/publish.js index 7f839d419..10d7dfe38 100644 --- a/ui/redux/actions/publish.js +++ b/ui/redux/actions/publish.js @@ -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)); }; diff --git a/web/setup/publish-v2.js b/web/setup/publish-v2.js index cd3c2926a..2c37a3825 100644 --- a/web/setup/publish-v2.js +++ b/web/setup/publish-v2.js @@ -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) => {