Well, I am saving db properties in a YAML file in a ruby
application (not Rails) and was wondering if an exception is raised if
the file specified is not found. If so which is error. I want to handle
the uncertainty in the availability of the file with rescue.
Actually let me improve my question. This is the erro I get
initialize': No such file or directory - file2.yaml (Errno::ENOENT) from C:/Ruby/lib/ruby/1.8/yaml.rb:143:inopen’
from C:/Ruby/lib/ruby/1.8/yaml.rb:143:in `load_file’
doesn’t make any sense.
Errno::ENOENT is a system error, which means “No such file or
These values are Constants defined in Errno, so you can see the possible
values via Errno.constansts.
With that piece of information, the error that you get means that in
yaml.rb, on line 143, you were trying to open the file “file2.yaml”
did not exist, probably because it is not in the current working
but maybe because you didn’t ever create it, or because you named it
“FILE2.YAML” and you have a case-sensitive file system.
On Sat, Jul 25, 2009 at 12:19 AM, Venkat A. <
Thanks for the reply Ray
I purposefully did not create the file to see what error will
be raised. I am sorry I failed to mention that. I am trying to ensure
that this error will not be thrown to the user when a file is not found.
Hence I want to handle it with rescue. How can I achieve this.
The usual way,
?> File.open(“fjaskfajs”) # Or, whatever code you have on line 3 of
p “file not found”
“file not found”
On Sat, Jul 25, 2009 at 10:37 AM, Venkat A. <