-
Notifications
You must be signed in to change notification settings - Fork 2
Cronus Errors
GitHub Actions edited this page Aug 21, 2026
·
4 revisions
The typed error hierarchy for @tundralibs/cronus.
All package errors extend CronusError, which extends BaseError
from Utils — so every error carries the
project-wide contract: typed context, cause chains, and JSON
serialisation.
BaseError (@tundralibs/utils)
└── CronusError
├── DuplicateJobError
├── JobNotFoundError
├── InvalidScheduleError
└── InvalidActionError
CronusError is also used directly to wrap foreign errors thrown by
job actions before they surface on the error event (the original
error is preserved as cause).
| Class | Thrown by | Context |
|---|---|---|
DuplicateJobError |
add/addOnce — name already registered |
{ name } |
JobNotFoundError |
get/remove/enable/disable/isRunning/trigger — unknown name |
{ name } |
InvalidScheduleError |
parseSchedule (and therefore add) — malformed expression |
{ expression, field?, reason } |
InvalidActionError |
add — action is not a function |
{ name } |
All registration errors are thrown synchronously at the call site — never deferred to tick time — so a mis-configured job fails the deploy, not the 03:00 run.
Branch with instanceof; read structured data from context:
import {
Cronus,
DuplicateJobError,
InvalidScheduleError,
} from '@tundralibs/cronus';
const cron = new Cronus();
const name = 'hourly-cleanup';
const schedule = '0 * * * *';
const action = () => {};
try {
cron.add(name, schedule, action);
} catch (e) {
if (e instanceof InvalidScheduleError) {
console.error(
`bad schedule '${e.context.expression}': ${e.context.reason}`,
);
} else if (e instanceof DuplicateJobError) {
// idempotent re-registration — ignore
} else {
throw e;
}
}- Cronus-Jobs - Where these errors surface
- Cronus-Schedule-Syntax - What makes a schedule invalid