require "rover_utils"

##############################################################################
#
# This class should be used rather than the standard Thread class so
# that when an Exception is thrown within a thread it will be caught and
# logged before being propagated onward.
#
##############################################################################
class RoverThread < Thread
   include LogHelper

   def initialize (*args, &block)
     super {
       begin
         yield(*args)
       rescue Exception => e
         syslog("! exception occurred within a thread")
         syslog("! exception: #{e}")
         backtrace = e.backtrace.join("\n")
         syslog("!backtrace: #{backtrace}")
         raise e
       end
     }
   end
   
end
