diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-20 01:25:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-20 01:25:55 +0000 |
commit | 97177a2d99f7c38d6085ccba343a980031aec7cf (patch) | |
tree | 006f7d88aff9629cb1fae9cc244afec1fb0b1ec8 /error.c | |
parent | 51c195948f32e86226d2a45f810e2d830b573435 (diff) | |
download | ruby-97177a2d99f7c38d6085ccba343a980031aec7cf.tar.gz |
refactor syntax error
* compile.c (append_compile_error): use rb_syntax_error_append.
* error.c (rb_syntax_error_append): append messages into a
SyntaxError exception instance.
* parse.y (yycompile0): make new SyntaxError instance in main
mode, otherwize error_buffer should be a SyntaxError if error
has occurred.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -104,12 +104,18 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column, rb_str_cat2(mesg, "\n"); rb_write_error_str(mesg); } - else if (NIL_P(exc)) { - VALUE mesg = rb_enc_str_new(0, 0, enc); - exc = err_vcatf(mesg, NULL, fn, line, fmt, args); - } else { - err_vcatf(exc, "\n", fn, line, fmt, args); + VALUE mesg; + const char *pre = NULL; + if (NIL_P(exc)) { + mesg = rb_enc_str_new(0, 0, enc); + exc = rb_class_new_instance(1, &mesg, rb_eSyntaxError); + } + else { + mesg = rb_attr_get(exc, idMesg); + pre = "\n"; + } + err_vcatf(mesg, pre, fn, line, fmt, args); } return exc; |