summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-20 08:18:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-20 08:18:16 +0000
commitfdc0d3306c856a604e5add86696173f21d8bb9c6 (patch)
tree87bf7c9eaa97d01c3c917dd552d508edd1d7dcce /error.c
parentb614db0432aa9ab228cc4eca773fdc30ec6c900a (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.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/error.c b/error.c
index dbbf0d0287..26dec201cd 100644
--- a/error.c
+++ b/error.c
@@ -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)) {