From 9a0d68890920e528cfd60901c238c6326460e4ee Mon Sep 17 00:00:00 2001 From: Michael Ficocelli Date: Mon, 28 Aug 2023 15:03:16 -0400 Subject: [PATCH] NETSCRIPT: Add more helpful error messages to getPurchasedServerCost (#757) --- src/NetscriptFunctions.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index e84d88a8b..8f5c8e266 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1161,7 +1161,11 @@ export const ns: InternalAPI = { const cost = getPurchaseServerCost(ram); if (cost === Infinity) { - helpers.log(ctx, () => `Invalid argument: ram='${ram}'`); + if (ram > getPurchaseServerMaxRam()) { + helpers.log(ctx, () => `Invalid argument: ram='${ram}' must not be greater than getPurchaseServerMaxRam`); + } else { + helpers.log(ctx, () => `Invalid argument: ram='${ram}' must be a positive power of 2`); + } return Infinity; }