Make invalid hostname better

This commit is contained in:
Olivier Gagnon
2022-07-27 00:59:43 -04:00
parent 7f72d77428
commit 315b2adf30
2 changed files with 2 additions and 3 deletions
+2 -1
View File
@@ -166,7 +166,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
const safeGetServer = function (hostname: string, ctx: NetscriptContext): BaseServer {
const server = GetServer(hostname);
if (server == null) {
throw ctx.makeRuntimeErrorMsg(`Invalid hostname: ${hostname}`);
const str = hostname === "" ? "'' (empty string)" : "'" + hostname + "'";
throw ctx.makeRuntimeErrorMsg(`Invalid hostname: ${str}`);
}
return server;
};