From 27e24a8173bff73258a87bd5d5cb35271d283c57 Mon Sep 17 00:00:00 2001 From: reality Date: Sun, 27 Jan 2013 15:19:56 +0000 Subject: [PATCH] Fixes for [#232] --- modules/timers/timers.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/timers/timers.js b/modules/timers/timers.js index f70a576..073114f 100644 --- a/modules/timers/timers.js +++ b/modules/timers/timers.js @@ -18,23 +18,31 @@ var timers = function(dbot) { setTimeout(function() { console.log('Running first timer at ' + new Date().toUTCString()); this.runningIntervals.push(this.api.addTimer(timeout, callback)); - callback(); + try { + callback(); + } catch(err) { + console.log('Callback failed: ' + err); + } }.bind(this), firstTimeout); } else { this.runningIntervals.push(setInterval(function() { console.log('Running subsequent timer at ' + new Date().toUTCString()); - callback(); + try { + callback(); + } catch(err) { + console.log('Callback failed: ' + err); + } }.bind(this), timeout)); } } }; this.onDestroy = function() { - for(var i=0;i