From: rpardee@... (Roy Pardee) Date: 2004-09-26T03:19:31+09:00 Subject: Nuby: How do I find out what exception was thrown? Greetings all, I'm using ruby v1.8 on winxp. I'm trying to get a script together to delete a particular file if it exists--here it is in full: #------------------------------ # KillOwnerLok.rb # Looks for Eudora's signal file and tries to delete it. # FileToKill = '\\\blackula\Profiles\Laurel\Application Data\Qualcomm\Eudora\owner.lok' if File.exist?(FileToKill) puts FileToKill + " found!" if File.delete(FileToKill) > 0 puts "Succesfully deleted " + FileToKill + "--you should be able to use Eudora now." else puts "Could not delete " + FileToKill + "for some reason--is Eudora open?" end else puts "Could not find " + FileToKill end # rescue # What would go here? #------------------------------ [Pls watch for line wrap...] If I try to run this while the file in question is opened by another process I get this output: ------------------------------------------ F:\>ruby KillOwnerLok.rb \\blackula\Profiles\Laurel\Application Data\Qualcomm\Eudora\owner.lok found! KillOwnerLok.rb:9:in `delete': Permission denied - \\blackula\Profiles\Laurel\Ap plication Data\Qualcomm\Eudora\owner.lok (Errno::EACCES) from KillOwnerLok.rb:9 ------------------------------------------ I'd like to print my "Could not delete..." message in a rescue section, but I don't know how to translate the error message from the output into something 'rescuable'. How do I do that? Thanks! -Roy