Which exceptions are you catching when you don't specify an exception class like this:
begin
# do something
rescue
puts "Exception!"
end
Which exceptions are you catching when you don't specify an exception class like this:
begin
# do something
rescue
puts "Exception!"
end
According to my copy of Programming Ruby 1.9,
A rescue clause with no parameter is treated as if it had a parameter of
StandardError
.
And here's the documentation from ruby-doc.org:
By default,
rescue
only interceptsStandardError
and its descendants, but you can specify which exceptions you want handled, as arguments. (This technique does not work whenrescue
is in statement-modifier position.)
The Why Not Wiki has the Exception hierarchy available if you need to reference it.
As a quick reference, the Exception classes that are not derived from StandardError
are:
fatal
NoMemoryError
ScriptError
SignalException
SystemExit
SystemStackError