From 412ce82aae2c85a1ad92da6c82f712091078d9ab Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Thu, 20 Nov 2025 00:27:30 -0800 Subject: [PATCH] chore: fix wording of error when an item goes negative (#3054) It would say "subtracting -1" instead of "adding -1" or "subtracting 1". Also mentioned the absolute count (that would be) after the operation. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3054 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/services/inventoryService.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 85329cb4..993ede7d 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1920,7 +1920,9 @@ export const addMiscItems = (inventory: TInventoryDatabaseDocument, itemsArray: if (MiscItems[itemIndex].ItemCount == 0) { MiscItems.splice(itemIndex, 1); } else if (MiscItems[itemIndex].ItemCount < 0) { - throw new Error(`inventory.MiscItems has a negative count for ${ItemType} after subtracting ${ItemCount}`); + throw new Error( + `Cannot remove ${ItemCount * -1}x ${ItemType} from MiscItems, would be left with ${MiscItems[itemIndex].ItemCount}` + ); } }); }; @@ -1943,7 +1945,7 @@ const applyArrayChanges = ( arr.splice(itemIndex, 1); } else if (arr[itemIndex].ItemCount < 0) { throw new Error( - `inventory.${key} has a negative count for ${change.ItemType} after subtracting ${change.ItemCount}` + `Cannot remove ${change.ItemCount * -1}x ${change.ItemType} from ${key}, would be left with ${arr[itemIndex].ItemCount}` ); } } @@ -1992,7 +1994,7 @@ export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawU RawUpgrades.splice(itemIndex, 1); } else if (RawUpgrades[itemIndex].ItemCount < 0) { throw new Error( - `inventory.RawUpgrades has a negative count for ${ItemType} after subtracting ${ItemCount}` + `Cannot remove ${ItemCount * -1}x ${ItemType} from RawUpgrades, would be left with ${RawUpgrades[itemIndex].ItemCount}` ); } }); @@ -2009,7 +2011,7 @@ export const addFusionTreasures = (inventory: TInventoryDatabaseDocument, itemsA FusionTreasures.splice(itemIndex, 1); } else if (FusionTreasures[itemIndex].ItemCount <= 0) { throw new Error( - `inventory.FusionTreasures has a negative count for ${ItemType} after subtracting ${ItemCount}` + `Cannot remove ${ItemCount * -1}x ${ItemType} from FusionTreasures, would be left with ${FusionTreasures[itemIndex].ItemCount}` ); } } else {