feat(medusa): PriceListImportStrategy descriptive errors (#4842)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(medusa): `PriceListImportStrategy` descriptive error handling
|
||||||
@@ -305,8 +305,8 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy {
|
|||||||
OperationType.PricesCreate
|
OperationType.PricesCreate
|
||||||
)
|
)
|
||||||
|
|
||||||
await Promise.all(
|
for (const op of priceImportOperations) {
|
||||||
priceImportOperations.map(async (op) => {
|
try {
|
||||||
await txPriceListService.addPrices(
|
await txPriceListService.addPrices(
|
||||||
priceListId,
|
priceListId,
|
||||||
(op.prices as PriceListPriceCreateInput[]).map((p) => {
|
(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)
|
await this.finalize(batchJob)
|
||||||
})
|
})
|
||||||
@@ -373,7 +375,7 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy {
|
|||||||
protected async downloadImportOpsFile(
|
protected async downloadImportOpsFile(
|
||||||
batchJob: BatchJob,
|
batchJob: BatchJob,
|
||||||
op: OperationType
|
op: OperationType
|
||||||
): Promise<TParsedProductImportRowData[]> {
|
): Promise<TParsedPriceListImportRowData[]> {
|
||||||
let data = ""
|
let data = ""
|
||||||
const transactionManager = this.transactionManager_ ?? this.manager_
|
const transactionManager = this.transactionManager_ ?? this.manager_
|
||||||
|
|
||||||
@@ -392,7 +394,7 @@ class PriceListImportStrategy extends AbstractBatchJobStrategy {
|
|||||||
})
|
})
|
||||||
readableStream.on("error", () => {
|
readableStream.on("error", () => {
|
||||||
// TODO: maybe should throw
|
// TODO: maybe should throw
|
||||||
resolve([] as TParsedProductImportRowData[])
|
resolve([] as TParsedPriceListImportRowData[])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user