From 8866dba90dc7e496afa04605d31685e5cd07ce65 Mon Sep 17 00:00:00 2001 From: yugui Date: Wed, 24 Jun 2009 16:08:16 +0000 Subject: merges r23837 from trunk into ruby_1_9_1. -- * parse.y (parser_set_encode): show the erred file name instead of the file that requires it. [ruby-core:24006] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 6596bf8af..735f31c2c 100644 --- a/parse.y +++ b/parse.y @@ -6113,13 +6113,23 @@ parser_set_encode(struct parser_params *parser, const char *name) { int idx = rb_enc_find_index(name); rb_encoding *enc; + VALUE excargs[3]; if (idx < 0) { - rb_raise(rb_eArgError, "unknown encoding name: %s", name); + VALUE rb_make_backtrace(void); + VALUE rb_make_exception(int, VALUE*); + + excargs[1] = rb_sprintf("unknown encoding name: %s", name); + error: + excargs[0] = rb_eArgError; + excargs[2] = rb_make_backtrace(); + rb_ary_unshift(excargs[2], rb_sprintf("%s:%d", ruby_sourcefile, ruby_sourceline)); + rb_exc_raise(rb_make_exception(3, excargs)); } enc = rb_enc_from_index(idx); if (!rb_enc_asciicompat(enc)) { - rb_raise(rb_eArgError, "%s is not ASCII compatible", rb_enc_name(enc)); + excargs[1] = rb_sprintf("%s is not ASCII compatible", rb_enc_name(enc)); + goto error; } parser->enc = enc; } -- cgit