Permalink
Browse files

mruby should print error properly

  • Loading branch information...
matz committed Jul 14, 2012
1 parent afb983e commit 72f7c51bc0bcef4096db8d57e7e5ab2a342e383f
Showing with 8 additions and 2 deletions.
  1. +4 −1 src/parse.y
  2. +4 −1 tools/mruby/mruby.c
View
@@ -4871,6 +4871,7 @@ static mrb_value
load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
{
int n;
+ mrb_value v;
if (!p) {
mrb_parser_free(p);
@@ -4900,7 +4901,9 @@ load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
if (c->dump_result) codedump_all(mrb, n);
if (c->no_exec) return mrb_fixnum_value(n);
}
- return mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
+ v = mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
+ if (!mrb->exc) return mrb_undef_value();
+ return v;
}
mrb_value
View
@@ -196,9 +196,12 @@ main(int argc, char **argv)
v = mrb_load_file_cxt(mrb, args.rfp, c);
}
mrbc_context_free(mrb, c);
- if (!mrb->exc && args.check_syntax) {
+ if (args.check_syntax) {
printf("Syntax OK\n");
}
+ else if (!mrb_undef_p(v) && mrb->exc) {
+ mrb_p(mrb, mrb_obj_value(mrb->exc));
+ }
}
cleanup(mrb, &args);

0 comments on commit 72f7c51

Please sign in to comment.