Skip to content

Commit

Permalink
added error handling on cron.ready.native
Browse files Browse the repository at this point in the history
  • Loading branch information
GhomKrosmonaute committed Nov 8, 2024
1 parent e8e8627 commit 6a480f7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/listeners/cron.ready.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@ export default new app.Listener({
event: "ready",
description: "Launch all cron jobs",
async run() {
let launched = 0

for (const cron of app.cronList.values()) {
cron.start()
try {
cron.start()
launched++
} catch (error) {
if (typeof error === "string" || error instanceof Error)
logger.error(error, cron.filepath, true)
else
logger.error(
"an error occurred while starting the cron job",
cron.filepath,
)
}
}

logger.success("All cron jobs launched")
logger.success(`launched ${launched} cron jobs`)
},
})

0 comments on commit 6a480f7

Please sign in to comment.