异常处理

def throw_if_true(param)
    begin
        raise "test exception" if param
    rescue Exception => e
        puts "rescue"
    ensure
         puts "ensure"
    end
end

throw_if_true(true)
# printed: "rescue" and "ensure"
throw_if_true(false)
# printed only "ensure"