Over the past few days, I've been converting from raising a hard error whenever NewEngine runs into a problem, to an error logging system. Below is a demonstration of this new system:
Previously, these commands would result in NewEngine raising a hard error.
Below is a manually raised hard error, which will still be available through the raiseHardError
command:
Converting to the new logging system is proving to be considerably time-consuming thus far.
This is mainly due to nested calling.
Let's use main.bat
calling to ic-loadObject.bat
, which then calls to objectManager.bat
as an example.
If an error happens in objectManager.bat
, any data loaded during the current script will need to be unloaded for safety reasons.
There are many instances of scripts calling other scripts with different inputs and expected outputs, which all need to be accounted for.
The below code is present in checkCodeSafety.bat
, a script which is incredibly important in preventing exploits leading to unwanted code execution:
Firstly, I need to unload any data checkCodeSafety.bat
might've loaded.
The script currently looks like this:
The data this script may load is checkString
and lineContent
.
To prevent any possible issue, I now also need to check every script which calls to checkCodeSafety.bat
, and make sure unloading these two values won't cause any problems.
The scripts which call to checkCodeSafety.bat
are devConsole.bat
and main.bat
.
First I add exit code checking to devConsole.bat
:
Next, I do the same to main.bat
:
And lastly, ic-loadObject.bat
:
In this case, it only took a few minutes to convert to the new error logging system.
If I had to deal with different inputs and outputs, this would have taken far longer.
You can think of this as a massive tree of script calls.
Fortunately, NewEngine is modular internally, and every script is separated for the most part, which reduces the risk of regression as I make big changes such as this one.