mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-09 14:57:33 +01:00
Fix an issue where an empty stack trace would appear in ns1 scripts
This commit is contained in:
parent
d6a7471e0b
commit
6661473adc
@ -376,7 +376,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
const makeRuntimeErrorMsg = function(caller, msg) {
|
const makeRuntimeErrorMsg = function(caller, msg) {
|
||||||
const stack = (new Error()).stack.split('\n').slice(1);
|
const stack = (new Error()).stack.split('\n').slice(1);
|
||||||
const scripts = workerScript.getServer().scripts;
|
const scripts = workerScript.getServer().scripts;
|
||||||
let userstack = [];
|
const userstack = [];
|
||||||
for(const stackline of stack) {
|
for(const stackline of stack) {
|
||||||
let filename;
|
let filename;
|
||||||
for(const script of scripts) {
|
for(const script of scripts) {
|
||||||
@ -398,13 +398,12 @@ function NetscriptFunctions(workerScript) {
|
|||||||
const lineMatch = line.match(lineRe);
|
const lineMatch = line.match(lineRe);
|
||||||
const funcMatch = line.match(funcRe);
|
const funcMatch = line.match(funcRe);
|
||||||
if(lineMatch && funcMatch) {
|
if(lineMatch && funcMatch) {
|
||||||
let func = funcMatch[1];
|
return {line: lineMatch[1], func: funcMatch[1]};
|
||||||
return {line: lineMatch[1], func: func};
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let call = {line: "-1", func: "unknown"};
|
let call = {line: "-1", func: "unknown"};
|
||||||
let chromeCall = parseChromeStackline(stackline);
|
const chromeCall = parseChromeStackline(stackline);
|
||||||
if (chromeCall) {
|
if (chromeCall) {
|
||||||
call = chromeCall;
|
call = chromeCall;
|
||||||
}
|
}
|
||||||
@ -430,7 +429,8 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workerScript.log(caller, msg);
|
workerScript.log(caller, msg);
|
||||||
const rejectMsg = `${caller}: ${msg}<br><br>Stack:<br>${userstack.join('<br>')}`
|
let rejectMsg = `${caller}: ${msg}`
|
||||||
|
if(userstack.length !== 0) rejectMsg += `<br><br>Stack:<br>${userstack.join('<br>')}`;
|
||||||
return makeRuntimeRejectMsg(workerScript, rejectMsg);
|
return makeRuntimeRejectMsg(workerScript, rejectMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user