This design prevents exclusion from your program and bubbling of the stack trace. It also returns this exception as a value that may be useful.
a = get_me_data rescue $!
After this line it awill contain either the requested data or an exception. You can then parse this exception and act accordingly.
def get_me_data
raise 'No data for you'
end
a = get_me_data rescue $!
puts "Execution carries on"
p a
More realistic example.
lines = File.readlines(filename) rescue $!
, ( , ..). .