Re: Question concerning ruby file access
- From: Peña, Botp <botp@xxxxxxxxxxxxxxxxx>
- Date: Wed, 29 Oct 2008 20:34:07 -0500
From: Stefan Salewski [mailto:mail@xxxxxxxxxxxx]
# Or in other words: I want to print a text like "File
# with filename "testfile" does not exist" when opening failed.
i usually think it like db's logical unit of work or transaction. i just wrap it w ruby's begin/end and a rescue check as mentioned by sebastian.
something like eg
begin* File.open("test.rbx") do |f|
* end
rescue =>e"No such file or directory - test.rbx"
p e.message
end
=> nil
note, you can have more rescues and finetune them. you can also make your own exceptions.. just continue reading on the pickaxe..
- References:
- Question concerning ruby file access
- From: Stefan Salewski
- Question concerning ruby file access
- Prev by Date: Sorting Array Of Dates
- Next by Date: Re: Sorting Array Of Dates
- Previous by thread: Re: Question concerning ruby file access
- Next by thread: Sorting Array Of Dates
- Index(es):