diff --git a/synced-cron-server.js b/synced-cron-server.js index 2378967..ded4241 100644 --- a/synced-cron-server.js +++ b/synced-cron-server.js @@ -225,11 +225,11 @@ SyncedCron._entryWrapper = function(entry) { } }); } catch(e) { - log.info('Exception "' + entry.name +'" ' + e.stack); + log.info('Exception "' + entry.name +'" ' + (e && e.stack || e)); self._collection.update({_id: jobHistory._id}, { $set: { finishedAt: new Date(), - error: e.stack + error: e && e.stack || e } }); } @@ -263,7 +263,12 @@ SyncedCron._laterSetInterval = function(fn, sched) { */ function scheduleTimeout(intendedAt) { if(!done) { - fn(intendedAt); + try { + fn(intendedAt); + } catch(e) { + log.info('Exception running scheduled job ' + (e && e.stack || e)); + } + t = SyncedCron._laterSetTimeout(scheduleTimeout, sched); } }