Understanding the Ruby Exception Hierarchy
Exceptions are just classes in Ruby. The exception exception hierarchy is made up of all the classes that inherit from Exception.
Here's a the exception hierarchy for Ruby 2.1's standard library.
Exception NoMemoryError ScriptError LoadError NotImplementedError SyntaxError SecurityError SignalException Interrupt StandardError -- default for rescue ArgumentError UncaughtThrowError EncodingError FiberError IOError EOFError IndexError KeyError StopIteration LocalJumpError NameError NoMethodError RangeError FloatDomainError RegexpError RuntimeError -- default for raise SystemCallError Errno::* ThreadError TypeError ZeroDivisionError SystemExit SystemStackError
The reason that exceptions are arranged into a class tree is so that you can easily rescue similar types of exception.
For example, consider the code:
begin do_something rescue StandardError => e end
This will rescue not only StandardError, but also any exception that inherits from it. That happens to be pretty much any exception you'll be interested in.
In your own code, you might have all of your custom exceptions inherit from a single base class:
module MyLib class Error < StandardError end class TimeoutError < Error end class ConnectionError < Error end end ... begin do_something rescue MyLib::Error => e # Rescues any of the exceptions defined above end