katsaii / catspeak-lang

A cross-platform modding language for GameMaker games.
https://www.katsaii.com/catspeak-lang/
MIT License
94 stars 6 forks source link

More descriptive runtime error messages when in debug mode #51

Open JujuAdams opened 1 year ago

JujuAdams commented 1 year ago

Ran into a confusing bug when trying to call this code:

draw_text(10, 10, string([1, 2]));

I had forgotten to add string as a function to the environment. Catspeak threw this error out:

___________________________________________
############################################################################################
ERROR in
action number 1
of Draw Event
for object Object1:

script_execute_ext argument 1 incorrect type (undefined) expecting a Number (YYGI32)
 at gml_Script___catspeak_expr_call__ (line 841) -         return script_execute_ext(calleeIdx, args_);
############################################################################################
gml_Script___catspeak_expr_call__ (line 841)
gml_Script_anon___catspeak_expr_call___gml_GlobalScript_scr_catspeak_codegen_25249___catspeak_expr_call___gml_GlobalScript_scr_catspeak_codegen (line 837) -     var args_ = array_map(args, function(f) { return f() });
gml_Script_array_map (line 8) -         _new[@ _i] = _function(_array[_i]);
gml_Script___catspeak_expr_call__ (line 837) -     var args_ = array_map(args, function(f) { return f() });
gml_Script___catspeak_function__ (line 668) -         value = program();
gml_Object_Object1_Draw_0 (line 2) - func();

Figured out what was going on but it'd good to have a clearer error message that'll direct me to the offending function call.

katsaii commented 4 months ago

Errors still kind of suck.