🐛Throw write exception with proper storage identifier

This commit is contained in:
Anton SHEPILOV
2024-12-19 18:33:43 +01:00
parent 93750c5afc
commit 0025964b68
@@ -70,18 +70,21 @@ export class OneOfStorageStrategy implements StorageConnectorAPI {
); );
// Log all errors and throw if all write operations fail // Log all errors and throw if all write operations fail
const errors = writeResults.filter(result => result.status === "rejected"); let errorsCount = 0;
errors.forEach((error, index) => { writeResults.forEach((result, index) => {
const storageId = this.storages[index].getId(); if (result.status === "rejected") {
logger.error( const storageId = this.storages[index].getId();
new OneOfStorageWriteOneFailedException( logger.error(
storageId, new OneOfStorageWriteOneFailedException(
`Error writing to storage ${storageId}`, storageId,
(error as PromiseRejectedResult).reason, `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`); throw new WriteFileException(`Write ${path} failed for all storages`);
} }