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 : #<SystemCallError: Success>
001 : #<Errno::EPERM: Operation not permitted>
002 : #<Errno::ENOENT: No such file or directory>
003 : #<Errno::ESRCH: No such process>
004 : #<Errno::EINTR: Interrupted system call>
005 : #<Errno::EIO: Input/output error>
006 : #<Errno::ENXIO: No such device or address>
007 : #<Errno::E2BIG: Argument list too long>
008 : #<Errno::ENOEXEC: Exec format error>
009 : #<Errno::EBADF: Bad file descriptor>
010 : #<Errno::ECHILD: No child processes>
011 : #<Errno::EAGAIN: Resource temporarily unavailable>
012 : #<Errno::ENOMEM: Cannot allocate memory>
013 : #<Errno::EACCES: Permission denied>
014 : #<Errno::EFAULT: Bad address>
015 : #<Errno::ENOTBLK: Block device required>
016 : #<Errno::EBUSY: Device or resource busy>
017 : #<Errno::EEXIST: File exists>
018 : #<Errno::EXDEV: Invalid cross-device link>
019 : #<Errno::ENODEV: No such device>
020 : #<Errno::ENOTDIR: Not a directory>
021 : #<Errno::EISDIR: Is a directory>
022 : #<Errno::EINVAL: Invalid argument>
023 : #<Errno::ENFILE: Too many open files in system>
024 : #<Errno::EMFILE: Too many open files>
025 : #<Errno::ENOTTY: Inappropriate ioctl for device>
026 : #<Errno::ETXTBSY: Text file busy>
027 : #<Errno::EFBIG: File too large>
028 : #<Errno::ENOSPC: No space left on device>
029 : #<Errno::ESPIPE: Illegal seek>
030 : #<Errno::EROFS: Read-only file system>
031 : #<Errno::EMLINK: Too many links>
032 : #<Errno::EPIPE: Broken pipe>
033 : #<Errno::EDOM: Numerical argument out of domain>
034 : #<Errno::ERANGE: Numerical result out of range>
035 : #<Errno::EDEADLK: Resource deadlock avoided>
036 : #<Errno::ENAMETOOLONG: File name too long>
037 : #<Errno::ENOLCK: No locks available>
038 : #<Errno::ENOSYS: Function not implemented>
039 : #<Errno::ENOTEMPTY: Directory not empty>
040 : #<Errno::ELOOP: Too many levels of symbolic links>
042 : #<Errno::ENOMSG: No message of desired type>
043 : #<Errno::EIDRM: Identifier removed>
044 : #<Errno::ECHRNG: Channel number out of range>
045 : #<Errno::EL2NSYNC: Level 2 not synchronized>
046 : #<Errno::EL3HLT: Level 3 halted>
047 : #<Errno::EL3RST: Level 3 reset>
048 : #<Errno::ELNRNG: Link number out of range>
049 : #<Errno::EUNATCH: Protocol driver not attached>
050 : #<Errno::ENOCSI: No CSI structure available>
051 : #<Errno::EL2HLT: Level 2 halted>
052 : #<Errno::EBADE: Invalid exchange>
053 : #<Errno::EBADR: Invalid request descriptor>
054 : #<Errno::EXFULL: Exchange full>
055 : #<Errno::ENOANO: No anode>
056 : #<Errno::EBADRQC: Invalid request code>
057 : #<Errno::EBADSLT: Invalid slot>
059 : #<Errno::EBFONT: Bad font file format>
060 : #<Errno::ENOSTR: Device not a stream>
061 : #<Errno::ENODATA: No data available>
062 : #<Errno::ETIME: Timer expired>
063 : #<Errno::ENOSR: Out of streams resources>
064 : #<Errno::ENONET: Machine is not on the network>
065 : #<Errno::ENOPKG: Package not installed>
066 : #<Errno::EREMOTE: Object is remote>
067 : #<Errno::ENOLINK: Link has been severed>
068 : #<Errno::EADV: Advertise error>
069 : #<Errno::ESRMNT: Srmount error>
070 : #<Errno::ECOMM: Communication error on send>
071 : #<Errno::EPROTO: Protocol error>
072 : #<Errno::EMULTIHOP: Multihop attempted>
073 : #<Errno::EDOTDOT: RFS specific error>
074 : #<Errno::EBADMSG: Bad message>
075 : #<Errno::EOVERFLOW: Value too large for defined data type>
076 : #<Errno::ENOTUNIQ: Name not unique on network>
077 : #<Errno::EBADFD: File descriptor in bad state>
078 : #<Errno::EREMCHG: Remote address changed>
079 : #<Errno::ELIBACC: Can not access a needed shared library>
080 : #<Errno::ELIBBAD: Accessing a corrupted shared library>
081 : #<Errno::ELIBSCN: .lib section in a.out corrupted>
082 : #<Errno::ELIBMAX: Attempting to link in too many shared libraries>
083 : #<Errno::ELIBEXEC: Cannot exec a shared library directly>
084 : #<Errno::EILSEQ: Invalid or incomplete multibyte or wide character>
085 : #<Errno::ERESTART: Interrupted system call should be restarted>
086 : #<Errno::ESTRPIPE: Streams pipe error>
087 : #<Errno::EUSERS: Too many users>
088 : #<Errno::ENOTSOCK: Socket operation on non-socket>
089 : #<Errno::EDESTADDRREQ: Destination address required>
090 : #<Errno::EMSGSIZE: Message too long>
091 : #<Errno::EPROTOTYPE: Protocol wrong type for socket>
092 : #<Errno::ENOPROTOOPT: Protocol not available>
093 : #<Errno::EPROTONOSUPPORT: Protocol not supported>
094 : #<Errno::ESOCKTNOSUPPORT: Socket type not supported>
095 : #<Errno::EOPNOTSUPP: Operation not supported>
096 : #<Errno::EPFNOSUPPORT: Protocol family not supported>
097 : #<Errno::EAFNOSUPPORT: Address family not supported by protocol>
098 : #<Errno::EADDRINUSE: Address already in use>
099 : #<Errno::EADDRNOTAVAIL: Cannot assign requested address>
100 : #<Errno::ENETDOWN: Network is down>
101 : #<Errno::ENETUNREACH: Network is unreachable>
102 : #<Errno::ENETRESET: Network dropped connection on reset>
103 : #<Errno::ECONNABORTED: Software caused connection abort>
104 : #<Errno::ECONNRESET: Connection reset by peer>
105 : #<Errno::ENOBUFS: No buffer space available>
106 : #<Errno::EISCONN: Transport endpoint is already connected>
107 : #<Errno::ENOTCONN: Transport endpoint is not connected>
108 : #<Errno::ESHUTDOWN: Cannot send after transport endpoint shutdown>
109 : #<Errno::ETOOMANYREFS: Too many references: cannot splice>
110 : #<Errno::ETIMEDOUT: Connection timed out>
111 : #<Errno::ECONNREFUSED: Connection refused>
112 : #<Errno::EHOSTDOWN: Host is down>
113 : #<Errno::EHOSTUNREACH: No route to host>
114 : #<Errno::EALREADY: Operation already in progress>
115 : #<Errno::EINPROGRESS: Operation now in progress>
116 : #<Errno::ESTALE: Stale NFS file handle>
117 : #<Errno::EUCLEAN: Structure needs cleaning>
118 : #<Errno::ENOTNAM: Not a XENIX named type file>
119 : #<Errno::ENAVAIL: No XENIX semaphores available>
120 : #<Errno::EISNAM: Is a named type file>
121 : #<Errno::EREMOTEIO: Remote I/O error>
122 : #<Errno::EDQUOT: Disk quota exceeded>
123 : #<SystemCallError: No medium found>
124 : #<SystemCallError: Wrong medium type>
125 : #<SystemCallError: Operation canceled>
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
===============================================================================