From a2575f2a6a24f6da6eb82d52bec1b7ad03a8bbf6 Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 7 Apr 2025 14:31:40 +0100 Subject: [PATCH] throw better error when empty list, underlying cause to be fixed --- Libraries/SPTarkov.Server.Core/Utils/RandomUtil.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/SPTarkov.Server.Core/Utils/RandomUtil.cs b/Libraries/SPTarkov.Server.Core/Utils/RandomUtil.cs index 2cb64fed..c240308f 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/RandomUtil.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/RandomUtil.cs @@ -115,6 +115,11 @@ public class RandomUtil(ISptLogger _logger, ICloner _cloner) // We can call `count` directly if it's a list if (collection is IList list) { + if (!list.Any()) + { + throw new InvalidOperationException("Sequence contains no elements."); + } + return list[GetInt(0, list.Count - 1)]; }