From 3dd5e7206eb5d4db19e35073cad9c4e5ca4d321e Mon Sep 17 00:00:00 2001 From: GhomKrosmonaute Date: Fri, 8 Nov 2024 14:03:39 +0100 Subject: [PATCH] enhanced the cron error handling --- src/app/cron.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/cron.ts b/src/app/cron.ts index 32f49b1..ec1dd04 100644 --- a/src/app/cron.ts +++ b/src/app/cron.ts @@ -1,9 +1,9 @@ import * as handler from "@ghom/handler" +import discord from "discord.js" import cron from "node-cron" import path from "path" import url from "url" -import discord from "discord.js" import * as util from "./util.ts" @@ -194,6 +194,9 @@ export function cronKeyToPattern(key: CronIntervalKey): string { } export function cronSimpleToPattern(simple: CronIntervalSimple): string { + if (!simple.duration || simple.duration < 0) + throw new CRON_Error("Invalid cron's schedule duration") + switch (simple.type) { case "minute": return `*/${simple.duration} * * * *`