diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-08 04:58:18 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-08 04:58:18 +0000 |
commit | e9650c0b077707168095891af6419ca148b94b38 (patch) | |
tree | f1850bf2e50690e592bd03f043585b3eb9278bd5 /hash.c | |
parent | 4832574b9272933259c841121f4780eb876d8863 (diff) |
* array.c (rb_ary_fetch, rb_ary_splice, rb_ary_store): Improve IndexError
messages [ruby-core:28394]
* hash.c (rb_hash_fetch_m): Improve KeyError message
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@27672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -570,7 +570,11 @@ rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash) if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) { if (block_given) return rb_yield(key); if (argc == 1) { - rb_raise(rb_eKeyError, "key not found"); + VALUE desc = rb_protect(rb_inspect, key, 0); + if (NIL_P(desc) || RSTRING_LEN(desc) > 65) { + desc = rb_any_to_s(key); + } + rb_raise(rb_eKeyError, "key not found: %s", RSTRING_PTR(desc)); } return if_none; } |