When a NS function throws an error, clear the script environment's runningFn flag to allow players to properly catch errors without the concurrent calls error screwing them over

This commit is contained in:
danielyxie
2018-10-09 13:45:30 -05:00
parent 7bb38ce89d
commit 7730c5d092

View File

@ -138,7 +138,18 @@ function startNetscript2Script(workerScript) {
throw workerScript;
}
runningFn = propName;
let result = f(...args);
// If the function throws an error, clear the runningFn flag first, and then re-throw it
// This allows people to properly catch errors thrown by NS functions without getting
// the concurrent call error above
let result;
try {
result = f(...args);
} catch(e) {
runningFn = null;
throw(e);
}
if (result && result.finally !== undefined) {
return result.finally(function () {
runningFn = null;