Hi all rubyists,

I apologize if my question irritates you. Now, for the last time, I use the 
following code to explain why I looked for "resume next" in ruby initially.

First, I fully agree:
1. Exceptions are better dealt locally.
2. There are no generic error handler.

I would also say that most exceptions we encountered in program are 
"expected" exceptions, for example, "file not found", "connection broken" 
etc. A really unexpected exception usally means a bug in the software, or 
something really weird happened. Under such case, their are not much 
difference if you catch/resue that or not. Keep that in mind, let's read the 
following code:

example 1: with resume next.

on error resume next
conn=tcpserver.connect(remote)
if conn==nil then
  #some problem with connection
  exit
end
f=File.open(testfile)
if f.class!=File then
  #cannot open file
  #do something with it
end
# normal processing...

See in the above code, error handling are in normal code, the "resume next" 
clause is only used to prevent the system from intercept the exception. In 
ruby, you might right some different, maybe better, code, but the key point 
is same: the programmer needs to expect where a possible error will occur. 
as far as I know, no language is clever enough to do that for you (including 
ruby).

I admit that ruby's error handling is different, and I got the answers. I 
appreciate all the suggestions including "callcc" etc. However, that's not 
what I want. Thanks again for all helps.

Shannon





_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963