From: "Ara.T.Howard" Date: 2004-07-02T23:52:54+09:00 Subject: Re: Exceptions list - Unix ENOENT not the name of the exception - what is? On Fri, 2 Jul 2004, Dick Davies wrote: > * Graham Nicholls [0723 13:23]: >> Austin Ziegler wrote: >> >>> >>>> ENOENT is the Unix error, not Ruby's. So, what is the exception for a >>>> missing file on IO.foreach, and how in general can I get a list of >>>> exceptions or find out which is the right one to use? >>> >>> Try rescuing Errno::ENOENT. > > Out of interest, is there anyway of knowing what exceptions a given > class can raise? > > I'd expect not, but I've been wrong before (as any regulars on this list > will know). ~/build/ruby > grep 'VALUE rb_e' *c error.c:VALUE rb_eException; error.c:VALUE rb_eSystemExit; error.c:VALUE rb_eInterrupt; error.c:VALUE rb_eSignal; error.c:VALUE rb_eFatal; error.c:VALUE rb_eStandardError; error.c:VALUE rb_eRuntimeError; error.c:VALUE rb_eTypeError; error.c:VALUE rb_eArgError; error.c:VALUE rb_eIndexError; error.c:VALUE rb_eRangeError; error.c:VALUE rb_eNameError; error.c:VALUE rb_eNoMethodError; error.c:VALUE rb_eSecurityError; error.c:VALUE rb_eNotImpError; error.c:VALUE rb_eNoMemError; error.c:VALUE rb_eScriptError; error.c:VALUE rb_eSyntaxError; error.c:VALUE rb_eLoadError; error.c:VALUE rb_eSystemCallError; eval.c:static VALUE rb_eLocalJumpError; eval.c:static VALUE rb_eSysStackError; eval.c:static VALUE rb_eval _((VALUE,NODE*)); eval.c:static VALUE rb_eThreadError; io.c:VALUE rb_eEOFError; io.c:VALUE rb_eIOError; numeric.c:VALUE rb_eZeroDivError; numeric.c:VALUE rb_eFloatDomainError; re.c:static VALUE rb_eRegexpError; these are most of the errors, all the Errno::xxx errors are made by SystemCallError: ~ > cat syserr.rb 255.times do |errno| se = SystemCallError.new(errno) next if se.message[%r/unknown error/io] printf "%-3.3d : %s\n", errno, se.inspect end ~ > ruby syserr.rb 000 : # 001 : # 002 : # 003 : # 004 : # 005 : # 006 : # 007 : # 008 : # 009 : # 010 : # 011 : # 012 : # 013 : # 014 : # 015 : # 016 : # 017 : # 018 : # 019 : # 020 : # 021 : # 022 : # 023 : # 024 : # 025 : # 026 : # 027 : # 028 : # 029 : # 030 : # 031 : # 032 : # 033 : # 034 : # 035 : # 036 : # 037 : # 038 : # 039 : # 040 : # 042 : # 043 : # 044 : # 045 : # 046 : # 047 : # 048 : # 049 : # 050 : # 051 : # 052 : # 053 : # 054 : # 055 : # 056 : # 057 : # 059 : # 060 : # 061 : # 062 : # 063 : # 064 : # 065 : # 066 : # 067 : # 068 : # 069 : # 070 : # 071 : # 072 : # 073 : # 074 : # 075 : # 076 : # 077 : # 078 : # 079 : # 080 : # 081 : # 082 : # 083 : # 084 : # 085 : # 086 : # 087 : # 088 : # 089 : # 090 : # 091 : # 092 : # 093 : # 094 : # 095 : # 096 : # 097 : # 098 : # 099 : # 100 : # 101 : # 102 : # 103 : # 104 : # 105 : # 106 : # 107 : # 108 : # 109 : # 110 : # 111 : # 112 : # 113 : # 114 : # 115 : # 116 : # 117 : # 118 : # 119 : # 120 : # 121 : # 122 : # 123 : # 124 : # 125 : # cheers. -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================