Kouhei Sutou
null+****@clear*****
Sun Aug 27 23:08:24 JST 2017
Kouhei Sutou 2017-08-27 23:08:24 +0900 (Sun, 27 Aug 2017) New Revision: 0d717dfaacb8f59f88549304d5c2347606c17a23 https://github.com/groonga/groonga/commit/0d717dfaacb8f59f88549304d5c2347606c17a23 Message: mrb eval: improve error Modified files: lib/mrb/mrb_eval_context.c plugins/ruby/eval.rb Modified: lib/mrb/mrb_eval_context.c (+5 -3) =================================================================== --- lib/mrb/mrb_eval_context.c 2017-08-27 22:52:22 +0900 (bf9cf321c) +++ lib/mrb/mrb_eval_context.c 2017-08-27 23:08:24 +0900 (146237f28) @@ -39,7 +39,8 @@ eval_context_compile(mrb_state *mrb, mrb_value self) ctx = mrbc_context_new(mrb); if (!ctx) { - mrb_raise(mrb,E_RUNTIME_ERROR, "mrbc_context_new failed."); + mrb_raise(mrb, E_RUNTIME_ERROR, + "[mruby][eval][compile] failed to allocate context"); } ctx->capture_errors = 1; @@ -47,7 +48,8 @@ eval_context_compile(mrb_state *mrb, mrb_value self) parser = mrb_parse_nstring(mrb, script, script_length, ctx); if (!parser) { mrbc_context_free(mrb, ctx); - mrb_raise(mrb,E_RUNTIME_ERROR, "mrb_parse_nstring failed."); + mrb_raise(mrb, E_RUNTIME_ERROR, + "[mruby][eval][compile] failed to allocate parser"); } if (parser->nerr > 0) { mrb_value errormessage = mrb_format(mrb, "line %S:%S: %S", @@ -57,7 +59,7 @@ eval_context_compile(mrb_state *mrb, mrb_value self) mrb_parser_free(parser); mrbc_context_free(mrb, ctx); - mrb_raisef(mrb, E_ARGUMENT_ERROR, "%S", errormessage); + mrb_raisef(mrb, E_SYNTAX_ERROR, "%S", errormessage); } proc = mrb_generate_code(mrb, parser); Modified: plugins/ruby/eval.rb (+1 -1) =================================================================== --- plugins/ruby/eval.rb 2017-08-27 22:52:22 +0900 (c746484b0) +++ plugins/ruby/eval.rb 2017-08-27 23:08:24 +0900 (e7619cf2a) @@ -16,7 +16,7 @@ module Groonga eval_context = EvalContext.new begin result = eval_context.eval(script) - rescue => error + rescue Exception => error writer.map("result", 1) do writer.write("exception") writer.map("exception", 1) do -------------- next part -------------- HTML����������������������������...Download