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

@ -166,7 +166,8 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
const safeGetServer = function (hostname: string, ctx: NetscriptContext): BaseServer { const safeGetServer = function (hostname: string, ctx: NetscriptContext): BaseServer {
const server = GetServer(hostname); const server = GetServer(hostname);
if (server == null) { if (server == null) {
throw ctx.makeRuntimeErrorMsg(`Invalid hostname: ${hostname}`); const str = hostname === "" ? "'' (empty string)" : "'" + hostname + "'";
throw ctx.makeRuntimeErrorMsg(`Invalid hostname: ${str}`);
} }
return server; return server;
}; };

@ -521,8 +521,6 @@ export class Sleeve extends Person {
this.shock = 1; this.shock = 1;
this.storedCycles = 0; this.storedCycles = 0;
this.sync = Math.max(this.memory, 1); this.sync = Math.max(this.memory, 1);
this.logs = [];
} }
/** /**