diff --git a/libs/micronaut-worker/src/main/java/com/agorapulse/worker/schedule/DefaultJobScheduler.java b/libs/micronaut-worker/src/main/java/com/agorapulse/worker/schedule/DefaultJobScheduler.java index 1130d8d3..c6663e56 100644 --- a/libs/micronaut-worker/src/main/java/com/agorapulse/worker/schedule/DefaultJobScheduler.java +++ b/libs/micronaut-worker/src/main/java/com/agorapulse/worker/schedule/DefaultJobScheduler.java @@ -80,7 +80,11 @@ public void schedule(com.agorapulse.worker.Job job) { if (LOG.isDebugEnabled()) { LOG.debug("Scheduling cron job {} [{}] for {}", configuration.getName(), configuration.getCron(), job.getSource()); } - taskScheduler.schedule(configuration.getCron(), job); + try { + taskScheduler.schedule(configuration.getCron(), job); + } catch (IllegalArgumentException e) { + throw new JobConfigurationException(job, "Failed to schedule job " + configuration.getName() + " declared in " + job.getSource() + ". Invalid CRON expression: " + configuration.getCron(), e); + } } else if (configuration.getFixedRate() != null) { Duration duration = configuration.getFixedRate(); if (LOG.isDebugEnabled()) {