Skip to content

Commit

Permalink
🐛Throw write exception with proper storage identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
shepilov committed Dec 19, 2024
1 parent 93750c5 commit 0025964
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,21 @@ export class OneOfStorageStrategy implements StorageConnectorAPI {
);

// Log all errors and throw if all write operations fail
const errors = writeResults.filter(result => result.status === "rejected");
errors.forEach((error, index) => {
const storageId = this.storages[index].getId();
logger.error(
new OneOfStorageWriteOneFailedException(
storageId,
`Error writing to storage ${storageId}`,
(error as PromiseRejectedResult).reason,
),
);
let errorsCount = 0;
writeResults.forEach((result, index) => {
if (result.status === "rejected") {
const storageId = this.storages[index].getId();
logger.error(
new OneOfStorageWriteOneFailedException(
storageId,
`Error writing to storage ${storageId}`,
(result as PromiseRejectedResult).reason,
),
);
errorsCount++;
}
});
if (errors.length === this.storages.length) {
if (errorsCount === this.storages.length) {
throw new WriteFileException(`Write ${path} failed for all storages`);
}

Expand Down

0 comments on commit 0025964

Please sign in to comment.