Skip to content

Commit e799f73

Browse files
committed
chore: add debugging information for #2394
1 parent baaa0cb commit e799f73

File tree

1 file changed

+17
-3
lines changed
  • Intersect.Server.Core/General

1 file changed

+17
-3
lines changed

Intersect.Server.Core/General/Time.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Intersect.GameObjects;
2+
using Intersect.Logging;
23
using Intersect.Server.Networking;
34
using Intersect.Utilities;
45

@@ -54,9 +55,22 @@ public static void Update()
5455
}
5556
else
5657
{
57-
sGameTime = sGameTime.Add(new TimeSpan(0, 0, 0, 0, (int)(1000 * timeBase.Rate)));
58-
59-
//Not sure if Rate is negative if time will go backwards but we can hope!
58+
var timeWas = sGameTime;
59+
var timeRate = timeBase.Rate;
60+
var addedTime = new TimeSpan(0, 0, 0, 0, (int)(1000 * timeRate));
61+
62+
// Not sure if Rate is negative if time will go backwards but we can hope!
63+
try
64+
{
65+
sGameTime = sGameTime.Add(addedTime);
66+
}
67+
catch (ArgumentOutOfRangeException exception)
68+
{
69+
// Log the error with the value of timeBase.Rate and pass the exception
70+
Log.Error(exception, $"Failed to update game time. Time was {timeWas}, Added Rate was {timeRate}, Added time span was {addedTime}");
71+
// Rethrow the exception to crash the server o_o !!!
72+
throw;
73+
}
6074
}
6175

6276
//Calculate what "timeRange" we should be in, if we're not then switch and notify the world

0 commit comments

Comments
 (0)