Can anybody help me on the rescue clause? I tried to catch file not found
error of file.open method, but I don’t know what type of error to use in
rescue clause. i tried to write nothing after rescue, it seems not catching
the error. Further more:
where can I find a reference to different kind of runtime errors? It
seems that there are no information on that (Exception Class?) in pickaxe…
in “rescue SyntaxError, NameError => boom”, is => used to denote a hash?
if so, why NameError is a hash? If not, maybe gavin can add this usage of =>
to the FunnySymbolsInCode FAQ…
Can anybody help me on the rescue clause? I tried to catch file not found
error of file.open method, but I don't know what type of error to use in
rescue clause. i tried to write nothing after rescue, it seems not catching
the error. Further more:
Well, what error ruby give you ?
pigeon% ls aa
ls: aa: No such file or directory
pigeon%
Can anybody help me on the rescue clause? I tried to catch file not found
error of file.open method, but I don’t know what type of error to use in
rescue clause. i tried to write nothing after rescue, it seems not catching
the error. Further more:
Shannon, each rescue needs the name of one or more Exception classes
to catch. I used irb to find out what exception File.open raises for
file not found:
irb(main):001:0> File.open("xxx.yyy")
Errno::ENOENT: No such file or directory - "xxx.yyy"
from (irb):1:in 'open'
from (irb):1
Looks like Errno::ENOENT is the exception, so this works:
begin
File.open(“xxx.yyy”)
rescue Errno::ENOENT
puts “caught”
end
where can I find a reference to different kind of runtime errors? It
seems that there are no information on that (Exception Class?) in pickaxe…
IIRC (I don’t have my copy of Pickaxe beside me) there are two lists
of exceptions in the Pickaxe, one in the “Exceptions, Catch, and
Throw” chapter and one in the description of the Exception class in
the “Standard Library” chapter. I don’t see them in my online copy so
it may be that those lists are actually illustrations, which don’t
appear in the online version.
···
On Tue, 3 Dec 2002 22:49:59 +0900, “Shannon Fang” xrfang@hotmail.com wrote:
in “rescue SyntaxError, NameError => boom”, is => used to denote a hash?
if so, why NameError is a hash? If not, maybe gavin can add this usage of =>
to the FunnySymbolsInCode FAQ…
Have you ever had pickaxe in your hands? Have you read it through at least
once? It has a big chapter dedicated to exceptions with a nice table of
exception inheritance tree. It has a very useful index too, by the way.
···
----- Original Message -----
From: “Shannon Fang” xrfang@hotmail.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, December 03, 2002 5:49 AM
Subject: exception types
Hi,
Can anybody help me on the rescue clause? I tried to catch file not found
error of file.open method, but I don’t know what type of error to use in
rescue clause. i tried to write nothing after rescue, it seems not
catching
the error. Further more:
where can I find a reference to different kind of runtime errors? It
seems that there are no information on that (Exception Class?) in
pickaxe…
in “rescue SyntaxError, NameError => boom”, is => used to denote a
hash?
if so, why NameError is a hash? If not, maybe gavin can add this usage of
=>
to the FunnySymbolsInCode FAQ…
in “rescue SyntaxError, NameError => boom”, is => used to denote a hash?
if so, why NameError is a hash? If not, maybe gavin can add this usage of =>
to the FunnySymbolsInCode FAQ…