rescue's syntax makes handling different exceptions in different ways easy: : rescue « Statement « Ruby






rescue's syntax makes handling different exceptions in different ways easy:


begin
  ... code here ...
rescue ZeroDivisionError
  ... code to rescue the zero division exception here ...
rescue YourOwnException
  ... code to rescue a different type of exception here ...
rescue
  ... code that rescues all other types of exception here ...
end

 








Related examples in the same category

1.C++, Java, and Ruby exception handling compared
2.how exceptions work in Ruby.
3.Handling Exceptions: 10 / 0
4.Handling Passed Exceptions
5.begin