Sha256: 76b876c3568973ee9b5d44ae3a251c24b568c5111b396d2e11ef2d9d6e8b1a57

Contents?: true

Size: 601 Bytes

Versions: 3

Compression:

Stored size: 601 Bytes

Contents

#This class behaves like a normal thread - but it shows error-messages and tracebacks. Normal threads dont do that.
class Knj::Thread < Thread
	attr_accessor :data
	
	def initialize(*args, &block)
		@data = {}
		raise "No block was given." if !block_given?
		
		abort_on_exception = true
		super(*args) do
			begin
				block.call(*args)
			rescue SystemExit
				exit
			rescue Exception => e
				print "Error: "
				puts e.inspect
				print "\n"
				puts e.backtrace
				print "\n\n"
			end
		end
	end
	
	def [](key)
		return @data[key]
	end
	
	def []=(key, value)
		return @data[key] = value
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knjrbfw-0.0.7 lib/knj/thread.rb
knjrbfw-0.0.4 lib/knj/thread.rb
knjrbfw-0.0.3 lib/knj/thread.rb