summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-08 22:30:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-08 22:30:20 +0000
commitb3c7867df7cd186e73021f0ed9d17680999f190f (patch)
tree54774b8ee973eaf2ce53de151f007bd77f13efd3 /error.c
parentb188d19ee080e954b9a86c746d0c0ee4068266c1 (diff)
* error.c (rb_syserr_new): new function to make SystemCallError
instance without errno. [EXPERIMENTAL] * error.c (rb_syserr_fail, rb_mod_syserr_fail): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/error.c b/error.c
index b355cf890c..29d93fead6 100644
--- a/error.c
+++ b/error.c
@@ -1532,18 +1532,29 @@ static VALUE
make_errno_exc(const char *mesg)
{
int n = errno;
- VALUE arg;
errno = 0;
if (n == 0) {
rb_bug("rb_sys_fail(%s) - errno == 0", mesg ? mesg : "");
}
+ return rb_syserr_new(n, mesg);
+}
+VALUE
+rb_syserr_new(int n, const char *mesg)
+{
+ VALUE arg;
arg = mesg ? rb_str_new2(mesg) : Qnil;
return rb_class_new_instance(1, &arg, get_syserr(n));
}
void
+rb_syserr_fail(int e, const char *mesg)
+{
+ rb_exc_raise(rb_syserr_new(e, mesg));
+}
+
+void
rb_sys_fail(const char *mesg)
{
rb_exc_raise(make_errno_exc(mesg));
@@ -1558,6 +1569,14 @@ rb_mod_sys_fail(VALUE mod, const char *mesg)
}
void
+rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
+{
+ VALUE exc = rb_syserr_new(e, mesg);
+ rb_extend_object(exc, mod);
+ rb_exc_raise(exc);
+}
+
+void
rb_sys_warning(const char *fmt, ...)
{
char buf[BUFSIZ];