Module: Termite::Thread

Defined in:
lib/termite.rb

Class Method Summary collapse

Class Method Details

.new(*args, &block) ⇒ Object



418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/termite.rb', line 418

def self.new(*args, &block)
  ::Thread.new do
    begin
      block.call
    rescue ::Exception
      if args[0].respond_to?(:warn)
        logger = args[0]
      else
        logger = ::Termite::Logger.new(*args)
      end
      logger.warn "Exception in thread: #{$!.message}"
      logger.warn "  Backtrace:\n#{$!.backtrace.join("\n")}"
    end
  end
end