Helpers to execute a block and either handle or ignore exceptions.
Execute a block, catching any raised exceptions and returning nil,
otherwise returns results of block.
- handler
- proc object to call with error string (defaults to nil)
# File util/try.rb, line 78
def try()
begin
yield
rescue Exception => e
if !$tryHandler.current_handler.nil?
$tryHandler.current_handler.call(e.message)
end
nil
end
end
Execute a block, catching any raised exceptions and returning nil,
otherwise returns results of block. XMLRPC Fault is handled specially.
- handler
- proc object to call with error string (defaults to nil)
# File util/try.rb, line 93
def trycall()
begin
yield
rescue XMLRPC::Exception => e
if !$tryHandler.current_handler.nil?
arr = ["XMLRPC"]
arr.push("code=#{e.faultCode}")
arr.push("text=\"#{e.faultString}\".")
$tryHandler.current_handler.call(arr.join(":"))
end
nil
rescue Exception => e
if !$tryHandler.current_handler.nil?
$tryHandler.current_handler.call(e.message)
end
nil
end
end