Skip to content

Commit

Permalink
Revert "refactor: use await with catch() pattern PE-4643"
Browse files Browse the repository at this point in the history
This reverts commit c59977b.
  • Loading branch information
fedellen committed Aug 7, 2024
1 parent c59977b commit 5287a5f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/node/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class TurboAuthenticatedNodeUploadService extends TurboAuthenticatedBaseU
const contentType =
mimeType === false ? 'application/octet-stream' : mimeType;

try {
const result = await this.uploadFile({
fileStreamFactory: () => createReadStream(absoluteFilePath),
fileSizeFactory: () => statSync(absoluteFilePath).size,
Expand All @@ -104,19 +105,18 @@ export class TurboAuthenticatedNodeUploadService extends TurboAuthenticatedBaseU
{ name: 'Content-Type', value: contentType },
],
},
}).catch((error: any) => {
this.logger.error(`Error uploading file: ${absoluteFilePath}`, {
message: error?.message,
stack: error?.stack
});
if (throwOnFailure) {
throw error;
}
errors.push(error);
});
fileResponses.push(result);
const relativePath = absoluteFilePath.replace(folderPath + '/', '');
paths[relativePath] = { id: result.id };
} catch (error) {
if (throwOnFailure) {
throw error;
}
this.logger.error(`Error uploading file: ${absoluteFilePath}`);
this.logger.error(error);
errors.push(error);
}

Check warning on line 119 in src/node/upload.ts

View check run for this annotation

Codecov / codecov/patch

src/node/upload.ts#L113-L119

Added lines #L113 - L119 were not covered by tests
};

await Promise.all(
Expand Down

0 comments on commit 5287a5f

Please sign in to comment.