diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-20 08:18:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-20 08:18:16 +0000 |
commit | fdc0d3306c856a604e5add86696173f21d8bb9c6 (patch) | |
tree | 87bf7c9eaa97d01c3c917dd552d508edd1d7dcce /error.c | |
parent | b614db0432aa9ab228cc4eca773fdc30ec6c900a (diff) |
* error.c (syserr_initialize): use Errno constants as default
errno for subclasses. [ruby-dev:20241]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -542,11 +542,17 @@ syserr_initialize(argc, argv, self) char *err; char *buf; VALUE error, mesg; + VALUE klass = rb_obj_class(self); - if (rb_scan_args(argc, argv, "11", &mesg, &error) == 1 && FIXNUM_P(mesg)) { + rb_scan_args(argc, argv, klass == rb_eSystemCallError ? "11" : "02", + &mesg, &error); + if (argc == 1 && FIXNUM_P(mesg)) { error = mesg; mesg = Qnil; } + if (klass != rb_eSystemCallError && NIL_P(error)) { + error = rb_const_get_at(klass, rb_intern("Errno")); + } err = strerror(NUM2LONG(error)); if (!err) err = "Unknown error"; if (RTEST(mesg)) { |