Page MenuHomeWildfire Games

Report GUI object script handler error stack
Needs ReviewPublic

Authored by elexis on Feb 8 2020, 12:14 AM.
This revision needs review, but there are no reviewers specified.



If a script handler assigned to a GUI object calls another script handler assigned to a GUI object, and that latter handler triggers a script error,
then only the error of the first script handler will be reported, but not the one that actually triggered that error.

This patch changes the reporting behavior to report the error where it first occurred, thus allowing the developer to see the line of code that fails.

Test Plan

For example when opening a GUI page (onPress script handler) that somewhere assigns a dropdown selection (onSelectionChange) and the selection change handler triggers an error, it will only complain about the user clicking the page-open button.

Index: binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlDropdown.js
--- binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlDropdown.js	(revision 23480)
+++ binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlDropdown.js	(working copy)
@@ -48,6 +48,7 @@
+		throw new Error();
 		if (!this.isInGuiUpdate)

Without this patch:

ERROR: JavaScript error: gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlDropdown.js line 42
Error: Errors executing script event "SelectionChange"

You see that this reporting behavior is problematic, because the developer can only see that a function assigned to onSelectionChange somewhere errored out, but not where it did.

With this patch:

ERROR: JavaScript error: gui/gamesetup/Pages/GameSetupPage/GameSettings/GameSettingControlDropdown.js line 51

With the patch one gets an exact line where the error happens (this is the inserted line).

Notice that this behavior is the same as in other calls with all other JS_CallFunction calls.

Event Timeline

elexis created this revision.Feb 8 2020, 12:14 AM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"
Executing section JS...
Executing section cli...

Link to build: