Ruby Rescue divide by zero exception
Rescue divide by zero exception.
# Rescue a Divide by Zero exception
num1 = 10
num2 = 0
def cont
puts "execution can continue"
end
begin
puts num1/num2
puts "execution continues."
# rescue ZeroDivisionError
# puts "A divide by zero exception occurred."
rescue IOError
puts "An I/O error occurred."
rescue
puts "An exception occurred."
cont
end