Is there a case where a ruby ​​“exception” could pass a “rescue object”?

Is there a way for raising something and an exception that does not come from Exception?

What I'm trying to avoid is something like:

require 'timeout'
begin
  timeout(1) {sleep(50)}
rescue StandardError => e
  puts e.message
end

I know that I can catch it with the “Exclusion of salvation” or more decisively, “Rescue object”, but for me it is a little strange.

+5
source share
1 answer

If you try to raise a non-class error Exception, you will get <TypeError: exception class/object expected>.

+3
source

All Articles