Skip to content

Commit

Permalink
feat(medusa): PriceListImportStrategy descriptive errors (#4842)
Browse files Browse the repository at this point in the history
  • Loading branch information
fPolic authored Aug 23, 2023
1 parent c585889 commit 8b86041
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-nails-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

feat(medusa): `PriceListImportStrategy` descriptive error handling
14 changes: 8 additions & 6 deletions packages/medusa/src/strategies/batch-jobs/price-list/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -316,8 +316,10 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy {
}
})
)
})
)
} catch (e) {
PriceListImportStrategy.throwDescriptiveError(op, e.message)
}
}

await this.finalize(batchJob)
})
Expand Down Expand Up @@ -373,7 +375,7 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy {
protected async downloadImportOpsFile(
batchJob: BatchJob,
op: OperationType
): Promise<TParsedProductImportRowData[]> {
): Promise<TParsedPriceListImportRowData[]> {
let data = ""
const transactionManager = this.transactionManager_ ?? this.manager_

Expand All @@ -392,7 +394,7 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy {
})
readableStream.on("error", () => {
// TODO: maybe should throw
resolve([] as TParsedProductImportRowData[])
resolve([] as TParsedPriceListImportRowData[])
})
})
}
Expand Down

0 comments on commit 8b86041

Please sign in to comment.