Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class · Ruby 3.1

StandardError

The most standard error types are subclasses of StandardError. A rescue clause without an explicit Exception class will rescue all StandardErrors (and only those).

Example
def foo
  raise "Oups"
end
foo rescue "Hello"   #=> "Hello"

On the other hand:

Example
require 'does/not/exist' rescue "Hi"

raises the exception:

LoadError: no such file to load -- does/not/exist