chore(medusa, workflows-sdk): Workflow default to throw the first error (#7442)
**What** Currently when a workflow fail it will throw an error which contains the messages of all error thrown durring the workflow lifetime. Therefore, in our cases we are always preventing workflow to throw and grab the first error that we then re throw. This pr eliminate that need by throwing back the first error among the error thrown by a workflow as it is the main case. In case someone need a special handling they can still set the option throwOnError to false and handle the error the way they need
This commit is contained in:
@@ -13,15 +13,10 @@ export const POST = async (
|
||||
const remoteQuery = req.scope.resolve("remoteQuery")
|
||||
const { id } = req.params
|
||||
|
||||
const { errors } = await archiveOrderWorkflow(req.scope).run({
|
||||
await archiveOrderWorkflow(req.scope).run({
|
||||
input: { orderIds: [req.validatedBody.order_id] },
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
if (Array.isArray(errors) && errors[0]) {
|
||||
throw errors[0].error
|
||||
}
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "order",
|
||||
variables: { id },
|
||||
|
||||
@@ -13,15 +13,10 @@ export const POST = async (
|
||||
const remoteQuery = req.scope.resolve("remoteQuery")
|
||||
const { id } = req.params
|
||||
|
||||
const { errors } = await completeOrderWorkflow(req.scope).run({
|
||||
await completeOrderWorkflow(req.scope).run({
|
||||
input: { orderIds: [req.validatedBody.order_id] },
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
if (Array.isArray(errors) && errors[0]) {
|
||||
throw errors[0].error
|
||||
}
|
||||
|
||||
const queryObject = remoteQueryObjectFromString({
|
||||
entryPoint: "order",
|
||||
variables: { id },
|
||||
|
||||
Reference in New Issue
Block a user