mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-08 11:29:19 +01:00
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:
@ -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;
|
||||
|
Reference in New Issue
Block a user