@@ -73,7 +73,8 @@ export class DirectUploadClient implements IDirectUploadClient {
7373 if ( axios . isCancel ( error ) ) {
7474 throw new FileUploadCancelError ( file . name , datasetId )
7575 }
76- throw new FileUploadError ( file . name , datasetId , error . message )
76+ const errorMessage = error instanceof Error ? error . message : 'Upload singlepart file failed'
77+ throw new FileUploadError ( file . name , datasetId , errorMessage )
7778 }
7879 }
7980
@@ -114,16 +115,20 @@ export class DirectUploadClient implements IDirectUploadClient {
114115 eTags [ `${ index + 1 } ` ] = eTag
115116 } catch ( error ) {
116117 if ( axios . isCancel ( error ) ) {
117- await this . abortMultipartUpload ( file . name , datasetId , destination . abortEndpoint )
118+ await this . abortMultipartUpload ( file . name , datasetId , destination . abortEndpoint as string )
118119 throw new FileUploadCancelError ( file . name , datasetId )
119120 }
120121 if ( retries < maxRetries ) {
121122 const backoffDelay = Math . pow ( 2 , retries ) * 1000
122123 await new Promise ( ( resolve ) => setTimeout ( resolve , backoffDelay ) )
123124 await uploadPart ( destinationUrl , index , retries + 1 )
124125 } else {
125- await this . abortMultipartUpload ( file . name , datasetId , destination . abortEndpoint )
126- throw new FilePartUploadError ( file . name , datasetId , error . message , index + 1 )
126+ await this . abortMultipartUpload ( file . name , datasetId , destination . abortEndpoint as string )
127+
128+ const errorMessage =
129+ error instanceof Error ? error . message : 'Upload part of multipart file failed'
130+
131+ throw new FilePartUploadError ( file . name , datasetId , errorMessage , index + 1 )
127132 }
128133 }
129134 }
@@ -165,7 +170,7 @@ export class DirectUploadClient implements IDirectUploadClient {
165170 ) : Promise < void > {
166171 return await axios
167172 . put (
168- buildRequestUrl ( destination . completeEndpoint ) ,
173+ buildRequestUrl ( destination . completeEndpoint as string ) ,
169174 eTags ,
170175 buildRequestConfig (
171176 true ,
@@ -177,7 +182,7 @@ export class DirectUploadClient implements IDirectUploadClient {
177182 . then ( ( ) => undefined )
178183 . catch ( async ( error ) => {
179184 if ( axios . isCancel ( error ) ) {
180- await this . abortMultipartUpload ( fileName , datasetId , destination . abortEndpoint )
185+ await this . abortMultipartUpload ( fileName , datasetId , destination . abortEndpoint as string )
181186 throw new FileUploadCancelError ( fileName , datasetId )
182187 }
183188 throw new MultipartCompletionError ( fileName , datasetId , error . message )
0 commit comments