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:
Frane Polić
2025-08-26 20:02:55 +02:00
committed by GitHub
parent 71818e43cb
commit 5382afccfa
4 changed files with 17 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---
chore(core-flows): throw Medusa error for exceptions in the fulifllment flows

View File

@@ -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`
)
}

View File

@@ -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})`
)
}

View File

@@ -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`
)
}