1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
<ppdoc>
<copyright>
Copyright (c) 2001 by Addison Wesley Longman. This
material may be distributed only subject to the terms and
conditions set forth in the Open Publication License, v1.0 or
later (the latest version is presently available at
http://www.opencontent.org/openpub/).
</copyright>
<class name="Errno" type="module">
<p/>
Ruby exception objects are subclasses of <classname>Exception</classname>. However,
operating systems typically report errors using plain
integers. Module <modulename>Errno</modulename> is created dynamically to map these
operating system errors to Ruby classes, with each error number generating
its own subclass of <exception>SystemCallError</exception>. As the subclass is created
in module <modulename>Errno</modulename>, its name will start <tt>Errno::</tt>.
<p/>
The names of the <modulename>Errno</modulename><tt>::</tt> classes depend on the environment in
which Ruby runs. On a typical Unix or Windows platform, there are
<modulename>Errno</modulename> classes such as <const>Errno::EACCES</const>,
<const>Errno::EAGAIN</const>, <const>Errno::EINTR</const>, and so on.
<p/>
The integer operating system error number corresponding to a
particular error is available as the class constant
<tt>Errno::</tt><em>error</em><tt>::Errno</tt>.
<p/>
<codefragment>
<fullcode><![CDATA[ Errno::EACCES::Errno
Errno::EAGAIN::Errno
Errno::EINTR::Errno
]]></fullcode><rubycode>
<tr>
<td><tt>Errno::EACCES::Errno</tt></td>
<td>»</td>
<td><tt>13</tt></td>
</tr>
<tr>
<td><tt>Errno::EAGAIN::Errno</tt></td>
<td>»</td>
<td><tt>11</tt></td>
</tr>
<tr>
<td><tt>Errno::EINTR::Errno</tt></td>
<td>»</td>
<td><tt>4</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
The full list of operating system errors on your particular
platform are available as the constants of <modulename>Errno</modulename>.
<p/>
<codefragment>
<fullcode><![CDATA[!- class Array
!- def inspect
!- s = self.to_a.collect{|i| i.to_s}.sort[0,7].join(', ')
!- s.inspect.gsub('"', '') + ", ..."
!- end
!- end
Errno.constants
]]></fullcode><rubycode>
<tr>
<td><tt>Errno.constants</tt></td>
<td>»</td>
<td><tt>E2BIG,<nbsp/>EACCES,<nbsp/>EADDRINUSE,<nbsp/>EADDRNOTAVAIL,<nbsp/>EADV,<nbsp/>EAFNOSUPPORT,<nbsp/>EAGAIN,<nbsp/>...</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
</class>
</ppdoc>
|