diff --git a/.changeset/red-nails-attend.md b/.changeset/red-nails-attend.md new file mode 100644 index 0000000000..fc292c6a2e --- /dev/null +++ b/.changeset/red-nails-attend.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +feat(medusa): `PriceListImportStrategy` descriptive error handling diff --git a/packages/medusa/src/strategies/batch-jobs/price-list/import.ts b/packages/medusa/src/strategies/batch-jobs/price-list/import.ts index daf75d4dc7..3c36ae71fd 100644 --- a/packages/medusa/src/strategies/batch-jobs/price-list/import.ts +++ b/packages/medusa/src/strategies/batch-jobs/price-list/import.ts @@ -305,8 +305,8 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy { OperationType.PricesCreate ) - await Promise.all( - priceImportOperations.map(async (op) => { + for (const op of priceImportOperations) { + try { await txPriceListService.addPrices( priceListId, (op.prices as PriceListPriceCreateInput[]).map((p) => { @@ -316,8 +316,10 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy { } }) ) - }) - ) + } catch (e) { + PriceListImportStrategy.throwDescriptiveError(op, e.message) + } + } await this.finalize(batchJob) }) @@ -373,7 +375,7 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy { protected async downloadImportOpsFile( batchJob: BatchJob, op: OperationType - ): Promise { + ): Promise { let data = "" const transactionManager = this.transactionManager_ ?? this.manager_ @@ -392,7 +394,7 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy { }) readableStream.on("error", () => { // TODO: maybe should throw - resolve([] as TParsedProductImportRowData[]) + resolve([] as TParsedPriceListImportRowData[]) }) }) }