From: Bob Gallagher Date: Fri, 17 Mar 2017 21:21:21 +0000 (-0400) Subject: Improve handling of unexpected package download/upload request errors X-Git-Tag: v2.0.0~30 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=2140fb647aae159dc38bd0893a94133220369de5;p=osm%2FUI.git Improve handling of unexpected package download/upload request errors RIFT-15846 Change-Id: Ic8816e9a5f778d05f9cfa82d5f5342bba8764a19 Signed-off-by: Bob Gallagher --- diff --git a/skyquake/plugins/composer/src/src/stores/CatalogPackageManagerStore.js b/skyquake/plugins/composer/src/src/stores/CatalogPackageManagerStore.js index ac7ee1f51..5ffe83f90 100644 --- a/skyquake/plugins/composer/src/src/stores/CatalogPackageManagerStore.js +++ b/skyquake/plugins/composer/src/src/stores/CatalogPackageManagerStore.js @@ -196,51 +196,57 @@ function updateStatusInfo(response) { }; const responseData = (response.data.output) ? response.data.output : response.data; const catalogPackage = response.state; - switch(response.data.status) { - case 'upload-progress': - statusInfo.pending = true; - statusInfo.progress = parseFloat(responseData.progress) || 0; - statusInfo.message = calculateUploadProgressMessage(catalogPackage.size, responseData.progress, responseData.bytesSent); - break; - case 'upload-success': - statusInfo.pending = true; - statusInfo.progress = 100; - statusInfo.message = 'Upload completed.'; - statusInfo.transactionId = responseData['transaction_id'] || responseData['transaction-id'] || catalogPackage.transactionId; - break; - case 'upload-error': - statusInfo.error = true; - statusInfo.message = responseData.message; - break; - case 'download-requested': - statusInfo.pending = true; - statusInfo.progress = 25; - statusInfo.transactionId = responseData['transaction_id'] || responseData['transaction-id'] || catalogPackage.transactionId; - break; - case 'pending': - statusInfo.pending = true; - statusInfo.progress = 50; - statusInfo.message = responseData.events[responseData.events.length - 1].text; - break; - case 'success': - statusInfo.success = true; - statusInfo.progress = 100; - statusInfo.message = responseData.events[responseData.events.length - 1].text; - if (catalogPackage.type === 'download') { - statusInfo.urlValidUntil = moment().add(defaults.downloadUrlTimeToLiveInMinutes, 'minutes').toISOString(); - if (responseData.filename) { - statusInfo.url = getCatalogPackageManagerServerOrigin() + '/api/export/' + responseData.filename; - } else { - statusInfo.url = getCatalogPackageManagerServerOrigin() + '/api/export/' + catalogPackage.transactionId + '.tar.gz'; + if ( typeof response.data.status !== "number" ) { + switch(response.data.status) { + case 'upload-progress': + statusInfo.pending = true; + statusInfo.progress = parseFloat(responseData.progress) || 0; + statusInfo.message = calculateUploadProgressMessage(catalogPackage.size, responseData.progress, responseData.bytesSent); + break; + case 'upload-success': + statusInfo.pending = true; + statusInfo.progress = 100; + statusInfo.message = 'Upload completed.'; + statusInfo.transactionId = responseData['transaction_id'] || responseData['transaction-id'] || catalogPackage.transactionId; + break; + case 'upload-error': + statusInfo.error = true; + statusInfo.message = responseData.message; + break; + case 'download-requested': + statusInfo.pending = true; + statusInfo.progress = 25; + statusInfo.transactionId = responseData['transaction_id'] || responseData['transaction-id'] || catalogPackage.transactionId; + break; + case 'pending': + statusInfo.pending = true; + statusInfo.progress = 50; + statusInfo.message = responseData.events[responseData.events.length - 1].text; + break; + case 'success': + statusInfo.success = true; + statusInfo.progress = 100; + statusInfo.message = responseData.events[responseData.events.length - 1].text; + if (catalogPackage.type === 'download') { + statusInfo.urlValidUntil = moment().add(defaults.downloadUrlTimeToLiveInMinutes, 'minutes').toISOString(); + if (responseData.filename) { + statusInfo.url = getCatalogPackageManagerServerOrigin() + '/api/export/' + responseData.filename; + } else { + statusInfo.url = getCatalogPackageManagerServerOrigin() + '/api/export/' + catalogPackage.transactionId + '.tar.gz'; + } } + break; + case 'failure': + statusInfo.error = true; + statusInfo.message = responseData.errors[0].value; + break; + default: + throw new ReferenceError('a status of "request", "success", "failure", "pending", "upload-completed", "upload-error", "download-requested", "upload-progress", "upload-action" is required'); } - break; - case 'failure': + } else { + // typically get here due to unexpected development errors (backend exceptions, down/up load server access issues) statusInfo.error = true; - statusInfo.message = responseData.errors[0].value; - break; - default: - throw new ReferenceError('a status of "request", "success", "failure", "pending", "upload-completed", "upload-error", "download-requested", "upload-progress", "upload-action" is required'); + statusInfo.message = responseData.statusText || 'Error'; } return Object.assign({}, catalogPackage, statusInfo); }