#Exception Handling
#Bullet Points
raise
orfail
#Demo / Live-code Overview
- Custom StandardError class
- raise makes RuntimeError with argument as message
begin
# do our work
rescue => e
# This will catch all StandardErrors and its subclasses
rescue SomeException => e
# Maybe do this
rescue Exception => e
# Maybe don't do this...
# Are you sure you want to catch everything?
else
# good, no exception surfaced!
ensure
# good or bad, this needs to be done
end
- Subclass StandardError
- THE PERILS OF 'RESCUE EXCEPTION'