Changing dirs and exceptions

  • Thread starter Witold Rugowski
  • Start date
W

Witold Rugowski

Hi!
I've been stuck with simple thing - I'm trying to change dir into not
existant directory. I'm using following code:

dir="no_such_one"
begin
Dir.chdir(dir)
rescue
into_dir = false; #we didn't make it
end

And resuce does not catch this:

Exception `Errno::ENOENT' at ./test.rb:33 - No such file or directory -
no_such_one

But Errno::ENOENT is child of StandardError, which should be catched by
default. So I'm probably making some stupid mistake - but I can not find
what one. Could someone help me?
 
W

Witold Rugowski

Witold said:
And resuce does not catch this:

Exception `Errno::ENOENT' at ./test.rb:33 - No such file or directory -
no_such_one

OK to be clear - execution is not stopped at this point (so resue is
somehow working) but I was not expecting this message on stderr. How to
get rid off this message?
 
N

nobu

Hi,

At Fri, 4 Aug 2006 21:33:10 +0900,
Witold Rugowski wrote in [ruby-talk:206240]:
Exception `Errno::ENOENT' at ./test.rb:33 - No such file or directory -
no_such_one

Seems like a message displayed when $DEBUG is turned on.
 
W

Witold Rugowski

unknown said:
Seems like a message displayed when $DEBUG is turned on.

That was it ;-)) In #! line I have left -d switch. It time for break ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,686
Latest member
scamivo

Latest Threads

Top