View Ruby Begin Rescue Exception Pics. When using raise without specifying an exception class, ruby will default to runtimeerror. You should manage expected errors.
Ruby Error Handling Beyond The Basics Sitepoint from uploads.sitepoint.com If you are opening a file, which does not exist, then if you did not for each rescue clause in the begin block, ruby compares the raised exception against each of the parameters in turn. Your own functions, ruby, or gems and frameworks can raise exceptions internally. Play around with these in your methods.
When using raise without specifying an exception class, ruby will default to runtimeerror.
In this case, the rescue clause inside of our begin end block will rescue any exceptions in its own context. The begin, end, rescue, and ensure methods are a little tricky to understand all together. Ruby helps us to handle these events in a way that is suitable to our needs. Begin # any exceptions in here.