Skip to content

Commit 5382afc

Browse files
fPolicolivermrbl
andauthored
chore(core-flows): throw Medusa error for exceptions in the fulifllment flows (medusajs#13302)
Co-authored-by: Oli Juhl <[email protected]>
1 parent 71818e4 commit 5382afc

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

.changeset/cuddly-baboons-cough.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@medusajs/core-flows": patch
3+
---
4+
5+
chore(core-flows): throw Medusa error for exceptions in the fulifllment flows

packages/core/core-flows/src/order/workflows/cancel-order-fulfillment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export const cancelOrderFulfillmentValidateOrder = createStep(
103103
(f) => f.id === input.fulfillment_id
104104
)
105105
if (!fulfillment) {
106-
throw new Error(
106+
throw new MedusaError(
107+
MedusaError.Types.INVALID_DATA,
107108
`Fulfillment with id ${input.fulfillment_id} not found in the order`
108109
)
109110
}

packages/core/core-flows/src/order/workflows/create-fulfillment.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ function prepareInventoryUpdate({
296296

297297
if (!reservations?.length) {
298298
if (item.variant?.manage_inventory) {
299-
throw new Error(
299+
throw new MedusaError(
300+
MedusaError.Types.INVALID_DATA,
300301
`No stock reservation found for item ${item.id} - ${item.title} (${item.variant_title})`
301302
)
302303
}

packages/core/core-flows/src/order/workflows/mark-order-fulfillment-as-delivered.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
ProductVariantDTO,
88
RegisterOrderDeliveryDTO,
99
} from "@medusajs/framework/types"
10-
import { FulfillmentWorkflowEvents, MathBN, Modules } from "@medusajs/framework/utils"
10+
import {
11+
FulfillmentWorkflowEvents,
12+
MathBN,
13+
MedusaError,
14+
Modules,
15+
} from "@medusajs/framework/utils"
1116
import {
1217
WorkflowData,
1318
WorkflowResponse,
@@ -102,7 +107,8 @@ export const orderFulfillmentDeliverablilityValidationStep = createStep(
102107
)
103108

104109
if (!orderFulfillment) {
105-
throw new Error(
110+
throw new MedusaError(
111+
MedusaError.Types.INVALID_DATA,
106112
`Fulfillment with id ${fulfillment.id} not found in the order`
107113
)
108114
}

0 commit comments

Comments
 (0)