Join Kevin Skoglund for an in-depth discussion in this video Handle specific exceptions, part of Ruby: Classes and Modules.
- [Instructor] In the previous movie we learned…about exceptions and how to handle them.…In this movie I want to build on that and learn…how we can handle specific exceptions.…That'll allow us to handle different exceptions…in different ways.…So in the last movie we saw that we can use…the rescue keyword to rescue any exceptions…that come up in the code immediately above it.…This is just using the rescue keyword by itself.…If we also add a class name after rescue…then it's going to rescue only exceptions…of that specified class.…So in this case, if something goes wrong…in the code up above, Ruby will first check…and see is the exception that's being raised…from that a zero division error?…If it is, it'll use the code following…that rescue in order to handle it.…
If it's not then it'll drop down to the next…rescue line and it'll see whether the exception…class being raised is a type error.…If it is, it'll use that code to handle it.…And if it's neither of those, then it'll go…down to the last one which is just a general…
- Defining a custom class
- Working with instances of a class
- Class and instance attributes and methods
- Class inheritance
- Working with dates and times
- Using modules as namespaces and mixins
- Raising and handling exceptions
Skill Level Beginner
2. Class Attributes and Methods
4. Dates and Times
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.