Handling Exceptions: 10 / 0 : rescue « Statement « Ruby






Handling Exceptions: 10 / 0



begin
  puts 10 / 0
rescue
  puts "You caused an error!"
end

 








Related examples in the same category

1.rescue's syntax makes handling different exceptions in different ways easy:
2.C++, Java, and Ruby exception handling compared
3.how exceptions work in Ruby.
4.Handling Passed Exceptions
5.begin