summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-02-20 08:15:59 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-02-20 08:15:59 +0000
commit6e16568665a242c645322d1f9cd144d55a87817e (patch)
tree8709bf78fbecd56a05ca7bb67b9c45a892841b0c
parent7b7f1309e8c3dbc3bb4408d56489ae5fba77d57a (diff)
Fix timer handling when Actions raise errors
-rw-r--r--ChangeLog5
-rw-r--r--lib/rbot/timer.rb14
2 files changed, 15 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b82b3b0f..2aea6f0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-02-20 Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
+
+ * Timers: failing timer actions don't prevent the global timer ticker
+ from functioning properly.
+
2007-02-18 Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
* Plugin: Provide a plugin.header file with boilerplate plugin
diff --git a/lib/rbot/timer.rb b/lib/rbot/timer.rb
index 5d527179..181dd2db 100644
--- a/lib/rbot/timer.rb
+++ b/lib/rbot/timer.rb
@@ -45,10 +45,16 @@ module Timer
# really short duration timers can overrun and leave @in negative,
# for these we set @in to @period
@in = @period if @in <= 0
- if(@data)
- @func.call(@data)
- else
- @func.call
+ begin
+ if(@data)
+ @func.call(@data)
+ else
+ @func.call
+ end
+ rescue => e
+ error "Timer action #{self.inspect} with function #{@func.inspect} failed with error #{e.inspect}"
+ error e.backtrace.join("\n")
+ # TODO maybe we want to block this Action?
end
return @once
end