diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-11 06:38:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-11 06:38:17 +0000 |
commit | 5a5a86cc527946fb40f241377179b0723f2348db (patch) | |
tree | ca199de0226f669396e84df7703e9b8eaef2d266 /hash.c | |
parent | 10ba3bdd533389fbd037be26930795d80d8f7104 (diff) | |
download | ruby-5a5a86cc527946fb40f241377179b0723f2348db.tar.gz |
hash.c: refine error messages
* hash.c (rb_hash_s_create): refine error messages.
* error.c (rb_builtin_class_name): share for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -15,6 +15,7 @@ #include "ruby/st.h" #include "ruby/util.h" #include "ruby/encoding.h" +#include "internal.h" #include <errno.h> #ifdef __APPLE__ @@ -392,11 +393,14 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass) hash = hash_alloc(klass); for (i = 0; i < RARRAY_LEN(tmp); ++i) { - VALUE v = rb_check_array_type(RARRAY_PTR(tmp)[i]); + VALUE e = RARRAY_PTR(tmp)[i]; + VALUE v = rb_check_array_type(e); VALUE key, val = Qnil; if (NIL_P(v)) { - rb_raise(rb_eArgError, "wrong element type (expected array)"); + rb_raise(rb_eArgError, "wrong element type %s at %ld (expected array)", + rb_builtin_class_name(e), i); + } switch (RARRAY_LEN(v)) { default: |