Ruby Error Handling

Published: Oct 25, 2018

Last updated: Oct 25, 2018

This is a basic example of raising and exception and rescueing the thrown exception.

def raise_and_rescue begin puts 'I am before the raise.' raise 'An error has occured.' puts 'I am after the raise.' rescue puts 'I am rescued.' end puts 'I am after the begin block.' end

Personal image

Dennis O'Keeffe

Byron Bay, Australia

Share this post

Recommended articles

Dennis O'Keeffe

2020-present Dennis O'Keeffe.

All Rights Reserved.