File: C:/Ruby27-x64/share/doc/ruby/html/SystemCallError.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>class SystemCallError - RDoc Documentation</title>
<script type="text/javascript">
var rdoc_rel_prefix = "./";
var index_rel_prefix = "./";
</script>
<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="class">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="class-metadata">
<div id="parent-class-section" class="nav-section">
<h3>Parent</h3>
<p class="link"><a href="StandardError.html">StandardError</a>
</div>
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
<h3>Methods</h3>
<ul class="link-list" role="directory">
<li ><a href="#method-c-3D-3D-3D">::===</a>
<li ><a href="#method-c-new">::new</a>
<li ><a href="#method-i-errno">#errno</a>
</ul>
</div>
</div>
</nav>
<main role="main" aria-labelledby="class-SystemCallError">
<h1 id="class-SystemCallError" class="class">
class SystemCallError
</h1>
<section class="description">
<p><a href="SystemCallError.html"><code>SystemCallError</code></a> is the base class for all low-level platform-dependent errors.</p>
<p>The errors available on the current platform are subclasses of <a href="SystemCallError.html"><code>SystemCallError</code></a> and are defined in the <a href="Errno.html"><code>Errno</code></a> module.</p>
<pre class="ruby"><span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">"does/not/exist"</span>)
</pre>
<p><em>raises the exception:</em></p>
<pre>Errno::ENOENT: No such file or directory - does/not/exist</pre>
</section>
<section id="5Buntitled-5D" class="documentation-section">
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Class Methods</h3>
</header>
<div id="method-c-3D-3D-3D" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
system_call_error === other → true or false
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Return <code>true</code> if the receiver is a generic <code>SystemCallError</code>, or if the error numbers <code>self</code> and <em>other</em> are the same.</p>
<div class="method-source-code" id="3D-3D-3D-source">
<pre>static VALUE
syserr_eqq(VALUE self, VALUE exc)
{
VALUE num, e;
if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) {
if (!rb_respond_to(exc, id_errno)) return Qfalse;
}
else if (self == rb_eSystemCallError) return Qtrue;
num = rb_attr_get(exc, id_errno);
if (NIL_P(num)) {
num = rb_funcallv(exc, id_errno, 0, 0);
}
e = rb_const_get(self, id_Errno);
if (FIXNUM_P(num) ? num == e : rb_equal(num, e))
return Qtrue;
return Qfalse;
}</pre>
</div>
</div>
</div>
<div id="method-c-new" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
new(msg, errno) → system_call_error_subclass
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>If <em>errno</em> corresponds to a known system error code, constructs the appropriate <a href="Errno.html"><code>Errno</code></a> class for that error, otherwise constructs a generic <a href="SystemCallError.html"><code>SystemCallError</code></a> object. The error number is subsequently available via the <a href="SystemCallError.html#method-i-errno"><code>errno</code></a> method.</p>
<div class="method-source-code" id="new-source">
<pre>static VALUE
syserr_initialize(int argc, VALUE *argv, VALUE self)
{
#if !defined(_WIN32)
char *strerror();
#endif
const char *err;
VALUE mesg, error, func, errmsg;
VALUE klass = rb_obj_class(self);
if (klass == rb_eSystemCallError) {
st_data_t data = (st_data_t)klass;
rb_scan_args(argc, argv, "12", &mesg, &error, &func);
if (argc == 1 && FIXNUM_P(mesg)) {
error = mesg; mesg = Qnil;
}
if (!NIL_P(error) && st_lookup(syserr_tbl, NUM2LONG(error), &data)) {
klass = (VALUE)data;
/* change class */
if (!RB_TYPE_P(self, T_OBJECT)) { /* insurance to avoid type crash */
rb_raise(rb_eTypeError, "invalid instance type");
}
RBASIC_SET_CLASS(self, klass);
}
}
else {
rb_scan_args(argc, argv, "02", &mesg, &func);
error = rb_const_get(klass, id_Errno);
}
if (!NIL_P(error)) err = strerror(NUM2INT(error));
else err = "unknown error";
errmsg = rb_enc_str_new_cstr(err, rb_locale_encoding());
if (!NIL_P(mesg)) {
VALUE str = StringValue(mesg);
if (!NIL_P(func)) rb_str_catf(errmsg, " @ %"PRIsVALUE, func);
rb_str_catf(errmsg, " - %"PRIsVALUE, str);
}
mesg = errmsg;
rb_call_super(1, &mesg);
rb_ivar_set(self, id_errno, error);
return self;
}</pre>
</div>
</div>
</div>
</section>
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
<header>
<h3>Public Instance Methods</h3>
</header>
<div id="method-i-errno" class="method-detail ">
<div class="method-heading">
<span class="method-callseq">
errno → integer
</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<p>Return this SystemCallError's error number.</p>
<div class="method-source-code" id="errno-source">
<pre>static VALUE
syserr_errno(VALUE self)
{
return rb_attr_get(self, id_errno);
}</pre>
</div>
</div>
</div>
</section>
</section>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>