Skip to content

Commit

Permalink
Changed: using DirectUploadClientError in DirectUploadClient
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Jun 3, 2024
1 parent b2329d3 commit 215fab7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/files/infra/clients/DirectUploadClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../../../core/infra/repositories/apiConfigBuilders'
import * as crypto from 'crypto'
import { IFilesRepository } from '../../domain/repositories/IFilesRepository'
import { DirectUploadClientError } from '../../domain/clients/DirectUploadClientError'

export class DirectUploadClient implements IDirectUploadClient {
private filesRepository: IFilesRepository
Expand Down Expand Up @@ -46,7 +47,7 @@ export class DirectUploadClient implements IDirectUploadClient {
timeout: 60000
})
} catch (error) {
throw new Error(`Error uploading file ${file.name}: ${error.message}`)
throw new DirectUploadClientError(`Error uploading file ${file.name}: ${error.message}`)
}
}

Expand Down Expand Up @@ -84,7 +85,7 @@ export class DirectUploadClient implements IDirectUploadClient {
await new Promise((resolve) => setTimeout(resolve, backoffDelay))
await uploadPart(destinationUrl, index, retries + 1)
} else {
throw new Error(`Error uploading part ${index + 1}: ${error.message}`)
throw new DirectUploadClientError(`Error uploading part ${index + 1}: ${error.message}`)
}
}
}
Expand All @@ -106,7 +107,7 @@ export class DirectUploadClient implements IDirectUploadClient {
.put(buildRequestUrl(completeEndpoint), eTags, buildRequestConfig(true, {}))
.then(() => undefined)
.catch((error) => {
throw new Error(`Error completing multipart upload: ${error.message}`)
throw new DirectUploadClientError(`Error completing multipart upload: ${error.message}`)
})
}

Expand Down

0 comments on commit 215fab7

Please sign in to comment.