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:
5
.changeset/cuddly-baboons-cough.md
Normal file
5
.changeset/cuddly-baboons-cough.md
Normal file
@@ -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
|
||||
)
|
||||
if (!fulfillment) {
|
||||
throw new Error(
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Fulfillment with id ${input.fulfillment_id} not found in the order`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -296,7 +296,8 @@ function prepareInventoryUpdate({
|
||||
|
||||
if (!reservations?.length) {
|
||||
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})`
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,12 @@ import {
|
||||
ProductVariantDTO,
|
||||
RegisterOrderDeliveryDTO,
|
||||
} from "@medusajs/framework/types"
|
||||
import { FulfillmentWorkflowEvents, MathBN, Modules } from "@medusajs/framework/utils"
|
||||
import {
|
||||
FulfillmentWorkflowEvents,
|
||||
MathBN,
|
||||
MedusaError,
|
||||
Modules,
|
||||
} from "@medusajs/framework/utils"
|
||||
import {
|
||||
WorkflowData,
|
||||
WorkflowResponse,
|
||||
@@ -102,7 +107,8 @@ export const orderFulfillmentDeliverablilityValidationStep = createStep(
|
||||
)
|
||||
|
||||
if (!orderFulfillment) {
|
||||
throw new Error(
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
`Fulfillment with id ${fulfillment.id} not found in the order`
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user