Skip to content

Update run to reset log suppression after running component #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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