123456789_123456789_123456789_123456789_123456789_

Exception: Timeout::Error

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, RuntimeError
Instance Chain:
self, RuntimeError
Inherits: RuntimeError
  • Object
Defined in: lib/timeout.rb

Overview

Raised by timeout when the block times out.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.catch(*args)

[ GitHub ]

  
# File 'lib/timeout.rb', line 32

def self.catch(*args)
  exc = new(*args)
  exc.instance_variable_set(:@thread, Thread.current)
  exc.instance_variable_set(:@catch_value, exc)
  ::Kernel.catch(exc) {yield exc}
end

Instance Attribute Details

#thread (readonly)

[ GitHub ]

  
# File 'lib/timeout.rb', line 30

attr_reader :thread

Instance Method Details

#exception

[ GitHub ]

  
# File 'lib/timeout.rb', line 39

def exception(*)
  # TODO: use Fiber.current to see if self can be thrown
  if self.thread == Thread.current
    bt = caller
    begin
      throw(@catch_value, bt)
    rescue UncaughtThrowError
    end
  end
  super
end