NETSCRIPT: Add more helpful error messages to getPurchasedServerCost (#757)

This commit is contained in:
Michael Ficocelli 2023-08-28 15:03:16 -04:00 committed by GitHub
parent b4f33fe655
commit 9a0d688909
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1161,7 +1161,11 @@ export const ns: InternalAPI<NSFull> = {
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;
}