Skip to content

Commit

Permalink
Update run to reset log suppression after running component (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Greenroyd committed Mar 1, 2024
2 parents a353844 + 6cda16d commit c49e518
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions BHoM_UI/Caller/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public virtual object Run(List<object> inputs)
{
try
{
return m_CompiledFunc(inputs.ToArray());
var result = m_CompiledFunc(inputs.ToArray());
ResetLogSuppression();
return result;
}
catch (InvalidCastException e)
{
Expand All @@ -88,10 +90,15 @@ public virtual object Run(List<object> inputs)
// Try to update the generic method to fit the input types
MethodInfo method = Engine.Base.Compute.MakeGenericFromInputs(originalMethod, inputs.Select(x => x?.GetType()).ToList());
m_CompiledFunc = method.ToFunc();
return m_CompiledFunc(inputs.ToArray());
var result = m_CompiledFunc(inputs.ToArray());
ResetLogSuppression();
return result;
}
else
{
ResetLogSuppression();
throw e;
}
}
}
else if (InputParams.Count <= 0)
Expand Down Expand Up @@ -306,6 +313,14 @@ protected virtual bool ShouldCalculateNewResult(List<object> inputs, ref object
return true;
}

/*************************************/

protected void ResetLogSuppression()
{
BH.Engine.Base.Compute.StopSuppressRecordingEvents(); //Ensure suppression is reset in case the calling method forgot to do it
BH.Engine.Base.Compute.ThrowErrorsAsExceptions(false); //Reset throwing errors to whatever the user may have set it to prior to running this method
}


/*************************************/
/**** Private Fields ****/
Expand Down

0 comments on commit c49e518

Please sign in to comment.