Add exception description for invalid child index.

This commit is contained in:
2023-05-25 15:02:03 +08:00
parent 5b510fa5da
commit 5f4d35b3b3
2 changed files with 9 additions and 4 deletions

View File

@@ -24,7 +24,10 @@ namespace Cryville.Crtr.Event {
= new Dictionary<Type, List<ContainerState>>();
public ContainerState GetChild(int index, Type handlerType) {
return TypedChildren[handlerType][index];
var list = TypedChildren[handlerType];
if (index < 0 || index >= list.Count)
throw new ArgumentOutOfRangeException("index", string.Format("{0}#{1} does not exist.", list[0].Handler.TypeName, index));
return list[index];
}
private bool m_active;