Forum: Ruby How to handle errors thrown by Shell.rb

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
91308e9bc88cb069fd1bcf88e910d042?d=identicon&s=25 Nick Snels (nicksnels)
on 2006-01-25 23:04
Hi,

I have this very simple code

require 'shell'
shell = Shell.new
shell.transact do
  shell.cat("#{path}")
end

Now suppose that the variable path is no longer available on disk or you
don't have permissions to access the file. How can I capture this error
and provide a helpful message? I have already tried it with rescue
Errno::EACCES but that didn't work. Thanks.

Kind regards,

Nick
This topic is locked and can not be replied to.