Skip to content

Commit

Permalink
mruby should print error properly
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Jul 14, 2012
1 parent afb983e commit 72f7c51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/parse.y
Expand Up @@ -4871,6 +4871,7 @@ static mrb_value
load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c) load_exec(mrb_state *mrb, parser_state *p, mrbc_context *c)
{ {
int n; int n;
mrb_value v;


if (!p) { if (!p) {
mrb_parser_free(p); mrb_parser_free(p);
Expand Down Expand Up @@ -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->dump_result) codedump_all(mrb, n);
if (c->no_exec) return mrb_fixnum_value(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 mrb_value
Expand Down
5 changes: 4 additions & 1 deletion tools/mruby/mruby.c
Expand Up @@ -196,9 +196,12 @@ main(int argc, char **argv)
v = mrb_load_file_cxt(mrb, args.rfp, c); v = mrb_load_file_cxt(mrb, args.rfp, c);
} }
mrbc_context_free(mrb, c); mrbc_context_free(mrb, c);
if (!mrb->exc && args.check_syntax) { if (args.check_syntax) {
printf("Syntax OK\n"); printf("Syntax OK\n");
} }
else if (!mrb_undef_p(v) && mrb->exc) {
mrb_p(mrb, mrb_obj_value(mrb->exc));
}
} }
cleanup(mrb, &args); cleanup(mrb, &args);


Expand Down

0 comments on commit 72f7c51

Please sign in to comment.