Guard for unnecessary exception

This commit is contained in:
jlewin 2019-03-19 15:12:24 -07:00
parent a7e0a674f1
commit af0413bd75

View file

@ -185,13 +185,19 @@ namespace MatterHackers.GCodeVisualizer
{
try
{
return renderFeatures[layerIndex][featureIndex];
var layer = renderFeatures[layerIndex];
if (featureIndex < layer.Count)
{
return layer[featureIndex];
}
}
catch
{
// Lazy guard for invalid indexes - callers should test for non-null values
return null;
}
// Callers should test for non-null values
return null;
}
}