diff --git a/web/setup/publish-v2.js b/web/setup/publish-v2.js index 37e841d42..e88c66a3e 100644 --- a/web/setup/publish-v2.js +++ b/web/setup/publish-v2.js @@ -78,29 +78,25 @@ export function makeResumableUploadRequest( const status = err.originalResponse ? err.originalResponse.getStatus() : 0; const errMsg = typeof err === 'string' ? err : err.message; - if (status === STATUS_CONFLICT) { - window.store.dispatch(doUpdateUploadProgress({ guid, status: 'conflict' })); - reject(new Error(`${status}: concurrent upload detected.`)); - } else { - const errToLog = - status === STATUS_LOCKED || errMsg === 'file currently locked' - ? 'File is locked. Try resuming after waiting a few minutes' - : err; - - window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' })); - reject( - // $FlowFixMe - flow's constructor for Error is incorrect. - new Error(errToLog, { - cause: { - url: uploader.url, - status, - ...(uploader._fingerprint ? { fingerprint: uploader._fingerprint } : {}), - ...(uploader._retryAttempt ? { retryAttempt: uploader._retryAttempt } : {}), - ...(uploader._offsetBeforeRetry ? { offsetBeforeRetry: uploader._offsetBeforeRetry } : {}), - }, - }) - ); + let customErr; + if (status === STATUS_LOCKED || errMsg === 'file currently locked') { + customErr = 'File is locked. Try resuming after waiting a few minutes'; } + + window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' })); + reject( + // $FlowFixMe - flow's constructor for Error is incorrect. + new Error(customErr || err, { + cause: { + url: uploader.url, + status, + ...(uploader._fingerprint ? { fingerprint: uploader._fingerprint } : {}), + ...(uploader._retryAttempt ? { retryAttempt: uploader._retryAttempt } : {}), + ...(uploader._offsetBeforeRetry ? { offsetBeforeRetry: uploader._offsetBeforeRetry } : {}), + ...(customErr ? { original: errMsg } : {}), + }, + }) + ); }, onProgress: (bytesUploaded, bytesTotal) => { const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2);