]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/timer.rb
timer: tick when rescheduling
[user/henk/code/ruby/rbot.git] / lib / rbot / timer.rb
index 181dd2db92137df90098be067787dfaf0eb6d770..bebe41f2fd589ba2fd9ccd41db8d354eb7dde0f2 100644 (file)
@@ -51,9 +51,9 @@ module Timer
         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")
+      rescue Exception => e
+        error "Timer action #{self.inspect} with function #{@func.inspect} failed!"
+        error e.pretty_inspect
         # TODO maybe we want to block this Action?
       end
       return @once
@@ -117,17 +117,21 @@ module Timer
 
     # block action with handle +handle+
     def block(handle)
+      raise "no such timer #{handle}" unless @timers[handle]
       @timers[handle].blocked = true
     end
 
     # unblock action with handle +handle+
     def unblock(handle)
+      raise "no such timer #{handle}" unless @timers[handle]
       @timers[handle].blocked = false
     end
 
     # reschedule action with handle +handle+ to change its period
     def reschedule(handle, period)
+      raise "no such timer #{handle}" unless @timers[handle]
       @timers[handle].reschedule(period)
+      tick
     end
 
     # you can call this when you know you're idle, or you can split off a