#See http://programblings.com/2008/04/11/irbrc-for-the-runtime-tramp/ 
# for more information on tramp_require :-)

def tramp_require(what, &block)
loaded, require_result = false, nil

begin
puts('', "requiring #{what}") if $debug_irbrc
require_result = require what
loaded = true
puts "successfully required #{what}" if $debug_irbrc

rescue Exception => ex
puts "** Unable to require '#{what}'"
exception_details = "#{ex.class}: #{ex.message}"
if $debug_irbrc
ex.backtrace.reverse.each{|l| exception_details << "\n #{l}"}
else
exception_details.insert(0, "--> ")
end
puts exception_details
end

if loaded and block_given?
puts "executing block for #{what}" if $debug_irbrc
yield
end

require_result
end