diff --git a/src/storage/s3.js b/src/storage/s3.js index e20d93651..1868a43fd 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -442,7 +442,7 @@ async function remove(apiConfig, filename) { // deleteObjects does not return error if key is not found const [error] = await safe(s3.deleteObjects(deleteParams)); - if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unable to remove ${deleteParams.Key}. ${formatError(error)}`); + if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unable to remove ${filename}. ${formatError(error)}`); } function chunk(array, size) { @@ -487,13 +487,14 @@ async function removeDir(apiConfig, pathPrefix, progressCallback) { } }; - progressCallback({ message: `Removing ${objects.length} files from ${objects[0].fullPath} to ${objects[objects.length-1].fullPath}` }); + const firstPath = objects[0].fullPath, lastPath = objects[objects.length-1].fullPath; + progressCallback({ message: `Removing ${objects.length} files from ${firstPath} to ${lastPath}` }); // deleteObjects does not return error if key is not found const [error] = await safe(s3.deleteObjects(deleteParams)); if (error) { - progressCallback({ message: `Unable to remove ${deleteParams.Key} ${error.message || error.Code}` }); - throw new BoxError(BoxError.EXTERNAL_ERROR, `Unable to remove ${deleteParams.Key}. error: ${error.message}`); + progressCallback({ message: `Unable to remove from ${firstPath} to ${lastPath} ${error.message || error.Code}` }); + throw new BoxError(BoxError.EXTERNAL_ERROR, `Unable to remove from ${firstPath} to ${lastPath}. error: ${error.message}`); } });