Log better error when trying to access out of bounds value on C# list

This commit is contained in:
Deukhoofd 2019-02-21 12:18:43 +01:00
parent 685cae2dc6
commit 40745a1935
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 6 additions and 0 deletions

View File

@ -62,6 +62,12 @@ namespace Upsilon.BaseTypes.UserData
{
return null;
}
if (i < 0 || i >= List.Count)
{
diagnostics.LogError($"Index out of bounds, index: '{i}'", span);
return new ScriptNull();
}
return List[i].ToScriptType();
}