Chapter 12 - Exceptions
Exercise 1: Rescuing Exceptions
The call to trip_over_curb raises an exception. Instead of allowing execution to halt, rescue the exception, and print the string "Caught you!".
def trip_over_curb
raise "WHOA!"
end
begin
trip_over_curb
rescue
puts "Caught you!"
endHere’s the output:
Caught you!