Commit 9e4be71f authored by Andrew Price's avatar Andrew Price
Browse files

duktape: Make backtraces more useful

Use duk_pcompile_string_filename() and duk_pcall() instead of
duk_peval() so we get the filename in js backtraces:

  mwjs error: RangeError: execution timeout
      at [anon] (duktape.c:72259) internal
      at fooCmd (.mw-script/mw.js:20) preventsyield
parent 89b6c0e3
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -678,8 +678,10 @@ int load_jsfile(FILE *f, const char *filename)

	interrupt = 0;
	start_timeout();
	/* TODO: Replace with duk_pcompile_string_filename() + duk_pcall() */
	err = duk_peval_string(ctx, buf);
	duk_push_string(ctx, filename);
	err = duk_pcompile_string_filename(ctx, 0, buf);
	if (err == 0)
		err = duk_pcall(ctx, 0);
	clear_timeout();

	if (err != 0)