William Liu

Errors and Exceptions

Summary

With a lot of programming languages, the exception hierarchy is built around two categories:

One general way to think about it is if the exception happens during the runtime (exectuion) of the application. A SyntaxError

Each of these have subclasses that depend on the language. For example, in Java it might look like:

Errors Descendants

Error Descendants

Exception Descendants

Exception Descendants

Ruby

In Ruby, exceptions are just classes in Ruby. The exception hierarchy is made up of all the classes that inherit from the Exception class. Some examples include:

https://ruby-doc.org/core-2.5.0/Exception.html

RuntimeError

RuntimeError is important because it is the default error class that is used when calling the standard Kernel#raise method that we all use to handle exceptions (e.g. in your code, you might raise.

Rescues

Exceptions are arranged into a class tree so you can easily rescue similar types of exceptions.

begin
  do_something
rescue StandardError => e
end