diff --git a/server/lib/modules/cronjobs.js b/server/lib/modules/cronjobs.js index e3b62adc..30bd581d 100644 --- a/server/lib/modules/cronjobs.js +++ b/server/lib/modules/cronjobs.js @@ -5,9 +5,15 @@ const logger = require("../winston"); let patientReprocessing = config.get("cronJobs:patientReprocessing"); +if (typeof patientReprocessing !== 'string') { + throw new TypeError('patientReprocessing must be a string!'); +} + cron.schedule(patientReprocessing, () => { - logger.info("Running cron job for patients reprocessing"); - matchMixin.reprocessPatients().then(() => { - logger.info("Done running cron job for patients reprocessing"); - }); + logger.info("Running cron job for patients reprocessing"); + matchMixin.reprocessPatients().then(() => { + logger.info("Done running cron job for patients reprocessing"); + }).catch((error) => { + logger.error("Error running cron job for patients reprocessing:", error); }); +});