Guard for unnecessary exception
This commit is contained in:
parent
a7e0a674f1
commit
af0413bd75
1 changed files with 9 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue