重新抛出异常

异常处理

# 任何方法都可能抛出错误
def method_with_exception()   
    begin
        raise "test exception"
    rescue Exception => e
        # 实现任意部分处理,
        # 并把错误传给调用方代码        
        raise e
    end
end

begin
    method_with_exception()
rescue Exception => e
    puts "Error: #{e}"
end