Is there a way to rescue all exceptions under a certain namespace?
For example, I want to rescue all of the Errno::* exceptions (Errno::ECONNRESET, Errno::ETIMEDOUT). I can go ahead and list them all out on my exception line, but I was wondering if I can do something like.
# my code
# handle exception
Errnois created dynamically to map these operating system errors to Ruby classes, with each error number generating its own subclass of
SystemCallError. As the subclass is created in module
Errno, its name will start
So you could trap
SystemCallError and then do a simple name check:
rescue SystemCallError => e raise e if(e.class.name.start_with?('Errno::')) # do your thing... end