How to handle errors thrown by Shell.rb

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs