Skip to content

Commit

Permalink
Remove unnecessary try/catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
Murderlon committed Sep 23, 2021
1 parent 2286afb commit 2a1ac74
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions packages/@uppy/aws-s3-multipart/src/MultipartUploader.js
Expand Up @@ -243,27 +243,21 @@ class MultipartUploader {

async #prepareUploadParts (candidates) {
this.lockedCandidatesForBatch.push(...candidates)
let result

try {
result = await this.#retryable({
attempt: () => this.options.prepareUploadParts({
key: this.key,
uploadId: this.uploadId,
partNumbers: candidates.map((index) => index + 1),
}),
})
} catch (error) {
throw new Error(error)
}

const valid = typeof result?.presignedUrls === 'object'
const result = await this.#retryable({
attempt: () => this.options.prepareUploadParts({
key: this.key,
uploadId: this.uploadId,
partNumbers: candidates.map((index) => index + 1),
}),
})

if (!valid) {
if (typeof result?.presignedUrls !== 'object') {
throw new TypeError(
'AwsS3/Multipart: Got incorrect result from `prepareUploadParts()`, expected an object `{ presignedUrls }`.'
)
}

return result
}

Expand Down

0 comments on commit 2a1ac74

Please sign in to comment.