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