vendor/bundle/ruby/1.8/gems/Ruby-MemCache-0.0.1/utils.rb
### Try the specified code block, printing the given 
Try the specified code block, printing the given
Try the specified code block printing the given
def try( msg, bind=nil )
		result = nil
		if msg =~ /^to\s/
			message = "Trying #{msg}..."
		else
			message = msg
		end
		begin
			rval = nil
			if block_given?
				rval = yield
			else
				file, line = caller(1)[0].split(/:/,2)
				rval = eval( msg, bind, file, line.to_i )
			end
			result = rval.inspect
		rescue Exception => err
			if err.backtrace
				nicetrace = err.backtrace.delete_if {|frame|
					/in `(try|eval)'/ =~ frame
				}.join("\n\t")
			else
				nicetrace = "Exception had no backtrace"
			end
			result = err.message + "\n\t" + nicetrace
		ensure
			puts result
		end
	end
def try ( msg , bind = nil ) result = nil if msg =~ / ^to \s / message = "Trying #{msg}..." else message = msg end begin rval = nil if block_given? rval = yield else file , line = caller ( 1 ) [ 0 ] . split ( / : / , 2 ) rval = eval ( msg , bind , file , line . to_i ) end result = rval . inspect rescue Exception => err if err . backtrace nicetrace = err . backtrace . delete_if { | frame | / in `(try|eval)' / =~ frame } . join ( "\n\t" ) else nicetrace = "Exception had no backtrace" end result = err . message + "\n\t" + nicetrace ensure puts result end end
Try the specified code block, printing the given
Try the specified code block printing the given
msg
bind