Try to make an error message more helpful

This commit is contained in:
Olivier Gagnon 2021-10-11 18:47:05 -04:00
parent 1ff7f4bcd4
commit faad0ae8a7
7 changed files with 67 additions and 59450 deletions

36
dist/vendor.bundle.js vendored

File diff suppressed because one or more lines are too long

@ -1,18 +1,18 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8"/>
<title>Bitburner</title> <title>Bitburner</title>
<link rel="apple-touch-icon" sizes="180x180" href="dist/apple-touch-icon.png" /> <link rel="apple-touch-icon" sizes="180x180" href="dist/apple-touch-icon.png"/>
<link rel="icon" type="image/png" sizes="32x32" href="dist/favicon-32x32.png" /> <link rel="icon" type="image/png" sizes="32x32" href="dist/favicon-32x32.png"/>
<link rel="icon" type="image/png" sizes="16x16" href="dist/favicon-16x16.png" /> <link rel="icon" type="image/png" sizes="16x16" href="dist/favicon-16x16.png"/>
<link rel="manifest" href="dist/site.webmanifest" /> <link rel="manifest" href="dist/site.webmanifest"/>
<link rel="mask-icon" href="dist/safari-pinned-tab.svg" color="#000000" /> <link rel="mask-icon" href="dist/safari-pinned-tab.svg" color="#000000"/>
<meta name="apple-mobile-web-app-title" content="Bitburner" /> <meta name="apple-mobile-web-app-title" content="Bitburner"/>
<meta name="application-name" content="Bitburner" /> <meta name="application-name" content="Bitburner"/>
<meta name="msapplication-TileColor" content="#000000" /> <meta name="msapplication-TileColor" content="#000000"/>
<meta name="msapplication-config" content="dist/browserconfig.xml" /> <meta name="msapplication-config" content="dist/browserconfig.xml"/>
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff"/>
<!-- Google Analytics --> <!-- Google Analytics -->
<script> <script>
@ -30,12 +30,12 @@
m.parentNode.insertBefore(a, m); m.parentNode.insertBefore(a, m);
})(window, document, "script", "https://www.google-analytics.com/analytics.js", "ga"); })(window, document, "script", "https://www.google-analytics.com/analytics.js", "ga");
</script> </script>
<script> <script>
ga("create", "UA-100157497-1", "auto"); ga("create", "UA-100157497-1", "auto");
ga("send", "pageview"); ga("send", "pageview");
</script> </script>
<style> <style>
body { body {
background-color: black; background-color: black;
@ -49,12 +49,9 @@
display: none; /* for Chrome, Safari, and Opera */ display: none; /* for Chrome, Safari, and Opera */
} }
</style> </style>
<link rel="shortcut icon" href="favicon.ico" /> <link rel="shortcut icon" href="favicon.ico"></head>
</head>
<body> <body>
<div id="root" /> <div id="root"/>
<script type="text/javascript" src="dist/vendor.bundle.js"></script> <script type="text/javascript" src="dist/vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
<script type="text/javascript" src="main.bundle.js"></script>
</body>
<!-- http://plaza.dsolver.ca/m/hydroflame4418 --> <!-- http://plaza.dsolver.ca/m/hydroflame4418 -->
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -13,13 +13,12 @@ export function netscriptDelay(time: number, workerScript: WorkerScript): Promis
} }
export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string { export function makeRuntimeRejectMsg(workerScript: WorkerScript, msg: string): string {
const lineNum = "";
const server = GetServer(workerScript.hostname); const server = GetServer(workerScript.hostname);
if (server == null) { if (server == null) {
throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`); throw new Error(`WorkerScript constructed with invalid server ip: ${workerScript.hostname}`);
} }
return "|" + server.hostname + "|" + workerScript.name + "|" + msg + lineNum; return "|" + server.hostname + "|" + workerScript.name + "|" + msg;
} }
export function resolveNetscriptRequestedThreads( export function resolveNetscriptRequestedThreads(

@ -124,10 +124,14 @@ function startNetscript2Script(workerScript: WorkerScript): Promise<WorkerScript
.catch((e) => reject(e)); .catch((e) => reject(e));
}).catch((e) => { }).catch((e) => {
if (e instanceof Error) { if (e instanceof Error) {
workerScript.errorMessage = makeRuntimeRejectMsg( if (e instanceof SyntaxError) {
workerScript, workerScript.errorMessage = makeRuntimeRejectMsg(workerScript, e.message + " (sorry we can't be more helpful)");
e.message + ((e.stack && "\nstack:\n" + e.stack.toString()) || ""), } else {
); workerScript.errorMessage = makeRuntimeRejectMsg(
workerScript,
e.message + ((e.stack && "\nstack:\n" + e.stack.toString()) || ""),
);
}
throw workerScript; throw workerScript;
} else if (isScriptErrorMessage(e)) { } else if (isScriptErrorMessage(e)) {
workerScript.errorMessage = e; workerScript.errorMessage = e;

@ -177,7 +177,7 @@ export function Root(props: IProps): React.ReactElement {
for (let i = 0; i < server.scripts.length; i++) { for (let i = 0; i < server.scripts.length; i++) {
if (filename == server.scripts[i].filename) { if (filename == server.scripts[i].filename) {
server.scripts[i].saveScript(filename, code, props.player.currentServer, server.scripts); server.scripts[i].saveScript(filename, code, props.player.currentServer, server.scripts);
saveObject.saveGame(); if (Settings.SaveGameOnFileSave) saveObject.saveGame();
props.router.toTerminal(); props.router.toTerminal();
return; return;
} }
@ -191,7 +191,7 @@ export function Root(props: IProps): React.ReactElement {
for (let i = 0; i < server.textFiles.length; ++i) { for (let i = 0; i < server.textFiles.length; ++i) {
if (server.textFiles[i].fn === filename) { if (server.textFiles[i].fn === filename) {
server.textFiles[i].write(code); server.textFiles[i].write(code);
saveObject.saveGame(); if (Settings.SaveGameOnFileSave) saveObject.saveGame();
props.router.toTerminal(); props.router.toTerminal();
return; return;
} }
@ -203,7 +203,7 @@ export function Root(props: IProps): React.ReactElement {
return; return;
} }
saveObject.saveGame(); if (Settings.SaveGameOnFileSave) saveObject.saveGame();
props.router.toTerminal(); props.router.toTerminal();
} }