chore(core-flows): throw Medusa error for exceptions in the fulifllment flows (#13302)
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore(core-flows): throw Medusa error for exceptions in the fulifllment flows
|
||||||
@@ -103,7 +103,8 @@ export const cancelOrderFulfillmentValidateOrder = createStep(
|
|||||||
(f) => f.id === input.fulfillment_id
|
(f) => f.id === input.fulfillment_id
|
||||||
)
|
)
|
||||||
if (!fulfillment) {
|
if (!fulfillment) {
|
||||||
throw new Error(
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.INVALID_DATA,
|
||||||
`Fulfillment with id ${input.fulfillment_id} not found in the order`
|
`Fulfillment with id ${input.fulfillment_id} not found in the order`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,7 +296,8 @@ function prepareInventoryUpdate({
|
|||||||
|
|
||||||
if (!reservations?.length) {
|
if (!reservations?.length) {
|
||||||
if (item.variant?.manage_inventory) {
|
if (item.variant?.manage_inventory) {
|
||||||
throw new Error(
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.INVALID_DATA,
|
||||||
`No stock reservation found for item ${item.id} - ${item.title} (${item.variant_title})`
|
`No stock reservation found for item ${item.id} - ${item.title} (${item.variant_title})`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,12 @@ import {
|
|||||||
ProductVariantDTO,
|
ProductVariantDTO,
|
||||||
RegisterOrderDeliveryDTO,
|
RegisterOrderDeliveryDTO,
|
||||||
} from "@medusajs/framework/types"
|
} from "@medusajs/framework/types"
|
||||||
import { FulfillmentWorkflowEvents, MathBN, Modules } from "@medusajs/framework/utils"
|
import {
|
||||||
|
FulfillmentWorkflowEvents,
|
||||||
|
MathBN,
|
||||||
|
MedusaError,
|
||||||
|
Modules,
|
||||||
|
} from "@medusajs/framework/utils"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
WorkflowData,
|
||||||
WorkflowResponse,
|
WorkflowResponse,
|
||||||
@@ -102,7 +107,8 @@ export const orderFulfillmentDeliverablilityValidationStep = createStep(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (!orderFulfillment) {
|
if (!orderFulfillment) {
|
||||||
throw new Error(
|
throw new MedusaError(
|
||||||
|
MedusaError.Types.INVALID_DATA,
|
||||||
`Fulfillment with id ${fulfillment.id} not found in the order`
|
`Fulfillment with id ${fulfillment.id} not found in the order`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user