@@ -5,7 +5,7 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { glob } from "glob"
|
||||
import logger from "../logger"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
import { ContainerRegistrationKeys, MedusaError } from "@medusajs/utils"
|
||||
|
||||
export const registerJobs = async (plugins) => {
|
||||
await Promise.all(
|
||||
@@ -50,8 +50,16 @@ const createJob = async ({ config, handler }) => {
|
||||
`${config.name}-as-step`,
|
||||
async (stepInput, stepContext) => {
|
||||
const { container } = stepContext
|
||||
const res = await handler(container)
|
||||
return new StepResponse(res, res)
|
||||
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
|
||||
try {
|
||||
const res = await handler(container)
|
||||
return new StepResponse(res, res)
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Scheduled job ${config.name} failed with error: ${error.message}`
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user