diff options
author | Ian Bull <irbull@eclipsesource.com> | 2024-09-04 23:27:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 08:27:58 +0200 |
commit | 17b5e98b822dc23407a0292dcf61e624fbf2a4b1 (patch) | |
tree | 3c421242aea0e0c7b88b1e4766a2fae3127a88f7 /ext/cron/01_cron.ts | |
parent | acd01eb2b41e37a480943f79cfa28fc220c4baca (diff) |
refactor(ext/cron): align error messages (#25300)
Aligns the error messages in the cron extension to be in-line with the
Deno style guide.
https://github.com/denoland/deno/issues/25269
Diffstat (limited to 'ext/cron/01_cron.ts')
-rw-r--r-- | ext/cron/01_cron.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/ext/cron/01_cron.ts b/ext/cron/01_cron.ts index 017da8ae2..b5c556a67 100644 --- a/ext/cron/01_cron.ts +++ b/ext/cron/01_cron.ts @@ -41,7 +41,9 @@ export function formatToCronSchedule( } else if (end === undefined && every !== undefined) { return "*/" + every; } else { - throw new TypeError("Invalid cron schedule"); + throw new TypeError( + `Invalid cron schedule: start=${start}, end=${end}, every=${every}`, + ); } } else { if (typeof exact === "number") { @@ -103,10 +105,14 @@ function cron( handler2?: () => Promise<void> | void, ) { if (name === undefined) { - throw new TypeError("Deno.cron requires a unique name"); + throw new TypeError( + "Cannot create cron job, a unique name is required: received 'undefined'", + ); } if (schedule === undefined) { - throw new TypeError("Deno.cron requires a valid schedule"); + throw new TypeError( + "Cannot create cron job, a schedule is required: received 'undefined'", + ); } schedule = parseScheduleToString(schedule); @@ -119,13 +125,15 @@ function cron( if (typeof handlerOrOptions1 === "function") { handler = handlerOrOptions1; if (handler2 !== undefined) { - throw new TypeError("Deno.cron requires a single handler"); + throw new TypeError( + "Cannot create cron job, a single handler is required: two handlers were specified", + ); } } else if (typeof handler2 === "function") { handler = handler2; options = handlerOrOptions1; } else { - throw new TypeError("Deno.cron requires a handler"); + throw new TypeError("Cannot create cron job: a handler is required"); } const rid = op_cron_create( |