-
Notifications
You must be signed in to change notification settings - Fork 62
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
Error Handler Report #3998
base: master
Are you sure you want to change the base?
Error Handler Report #3998
Conversation
WalkthroughThe changes introduce a new boolean property Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
Ginger/GingerCoreCommon/Repository/BusinessFlowLib/ErrorHandler.cs (1)
Line range hint
26-26
: Consider addressing or clarifying the TODO commentThe TODO comment "change add core" lacks context and clarity. If this is still relevant, it should be clarified or addressed. If not, it should be removed to prevent technical debt.
Would you like me to help create a GitHub issue to track this technical debt item?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
Ginger/GingerCoreCommon/Repository/BusinessFlowLib/ErrorHandler.cs
(2 hunks)Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs
(2 hunks)
🔇 Additional comments (2)
Ginger/GingerCoreCommon/Repository/BusinessFlowLib/ErrorHandler.cs (1)
72-72
: Verify thread-safety considerations
The IsAddedToReport
flag maintains state that could be accessed from multiple threads during error handling. Consider:
- Potential race conditions if multiple threads process errors simultaneously
- When/how this flag gets reset
- Impact on parallel execution of activities
Let's verify the usage pattern:
Ginger/GingerCoreNET/Run/GingerExecutionEngine.cs (1)
4000-4000
: Integration point looks correct
The call to CalculateErrorHandlersActivtyEnd
is placed appropriately in the RunActivity
method after activity execution is complete.
@@ -69,6 +69,7 @@ public class ErrorHandler : Activity, IErrorHandler | |||
{ | |||
private eHandlerType mHandlerType; | |||
public bool IsSelected { get; set; } | |||
public bool IsAddedToReport { get; set; } = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider following existing property patterns and adding documentation
The new IsAddedToReport
property deviates from the established patterns in the class:
- Missing the
[IsSerializedForLocalRepository]
attribute that other properties have - No XML documentation explaining its purpose
- Different implementation pattern compared to other properties (auto-property vs. backing field)
Consider applying this refactor to maintain consistency:
+ private bool mIsAddedToReport;
+ /// <summary>
+ /// Indicates whether this error handler has been added to the report
+ /// </summary>
+ [IsSerializedForLocalRepository]
+ public bool IsAddedToReport
+ {
+ get { return mIsAddedToReport; }
+ set { if (mIsAddedToReport != value) { mIsAddedToReport = value; OnPropertyChanged(nameof(IsAddedToReport)); } }
+ }
- public bool IsAddedToReport { get; set; } = false;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public bool IsAddedToReport { get; set; } = false; | |
private bool mIsAddedToReport; | |
/// <summary> | |
/// Indicates whether this error handler has been added to the report | |
/// </summary> | |
[IsSerializedForLocalRepository] | |
public bool IsAddedToReport | |
{ | |
get { return mIsAddedToReport; } | |
set { if (mIsAddedToReport != value) { mIsAddedToReport = value; OnPropertyChanged(nameof(IsAddedToReport)); } } | |
} |
|
||
private void CalculateErrorHandlersActivtyEnd(Activity activity) | ||
{ | ||
|
||
var errorHandlerList = CurrentBusinessFlow.Activities.Where(x => x.GetType() == typeof(ErrorHandler) && x.Status != eRunStatus.Skipped); | ||
|
||
foreach (ErrorHandler errActivity in errorHandlerList) | ||
{ | ||
if ( activity.EndTimeStamp > errActivity.EndTimeStamp && activity.Status == eRunStatus.Failed && !errActivity.IsAddedToReport) | ||
{ | ||
uint evetTime = RunListenerBase.GetEventTime(); | ||
foreach (RunListenerBase runnerListener in mRunListeners) | ||
{ | ||
runnerListener.ActivityEnd(evetTime, errActivity); | ||
} | ||
errActivity.IsAddedToReport = true; | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Review error handler activity end time calculation logic
The new method has some potential issues:
- The LINQ query to filter error handlers could be optimized by combining conditions
- The timestamp comparison lacks null checks which could cause NullReferenceException
- The method name has a typo ("Activty" instead of "Activity")
- The code formatting is inconsistent with extra blank lines
Here's a suggested refactor to address these issues:
-private void CalculateErrorHandlersActivtyEnd(Activity activity)
+private void CalculateErrorHandlerActivityEnd(Activity activity)
{
- var errorHandlerList = CurrentBusinessFlow.Activities.Where(x => x.GetType() == typeof(ErrorHandler) && x.Status != eRunStatus.Skipped);
+ if (activity?.EndTimeStamp == null || activity.Status != eRunStatus.Failed)
+ {
+ return;
+ }
+ var errorHandlerList = CurrentBusinessFlow.Activities
+ .OfType<ErrorHandler>()
+ .Where(x => x.Status != eRunStatus.Skipped &&
+ x.EndTimeStamp != null &&
+ !x.IsAddedToReport);
- foreach (ErrorHandler errActivity in errorHandlerList)
- {
- if ( activity.EndTimeStamp > errActivity.EndTimeStamp && activity.Status == eRunStatus.Failed && !errActivity.IsAddedToReport)
- {
- uint evetTime = RunListenerBase.GetEventTime();
- foreach (RunListenerBase runnerListener in mRunListeners)
- {
- runnerListener.ActivityEnd(evetTime, errActivity);
- }
- errActivity.IsAddedToReport = true;
- }
- }
+ foreach (ErrorHandler errHandler in errorHandlerList)
+ {
+ if (activity.EndTimeStamp > errHandler.EndTimeStamp)
+ {
+ uint eventTime = RunListenerBase.GetEventTime();
+ foreach (RunListenerBase runnerListener in mRunListeners)
+ {
+ runnerListener.ActivityEnd(eventTime, errHandler);
+ }
+ errHandler.IsAddedToReport = true;
+ }
+ }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
private void CalculateErrorHandlersActivtyEnd(Activity activity) | |
{ | |
var errorHandlerList = CurrentBusinessFlow.Activities.Where(x => x.GetType() == typeof(ErrorHandler) && x.Status != eRunStatus.Skipped); | |
foreach (ErrorHandler errActivity in errorHandlerList) | |
{ | |
if ( activity.EndTimeStamp > errActivity.EndTimeStamp && activity.Status == eRunStatus.Failed && !errActivity.IsAddedToReport) | |
{ | |
uint evetTime = RunListenerBase.GetEventTime(); | |
foreach (RunListenerBase runnerListener in mRunListeners) | |
{ | |
runnerListener.ActivityEnd(evetTime, errActivity); | |
} | |
errActivity.IsAddedToReport = true; | |
} | |
} | |
} | |
private void CalculateErrorHandlerActivityEnd(Activity activity) | |
{ | |
if (activity?.EndTimeStamp == null || activity.Status != eRunStatus.Failed) | |
{ | |
return; | |
} | |
var errorHandlerList = CurrentBusinessFlow.Activities | |
.OfType<ErrorHandler>() | |
.Where(x => x.Status != eRunStatus.Skipped && | |
x.EndTimeStamp != null && | |
!x.IsAddedToReport); | |
foreach (ErrorHandler errHandler in errorHandlerList) | |
{ | |
if (activity.EndTimeStamp > errHandler.EndTimeStamp) | |
{ | |
uint eventTime = RunListenerBase.GetEventTime(); | |
foreach (RunListenerBase runnerListener in mRunListeners) | |
{ | |
runnerListener.ActivityEnd(eventTime, errHandler); | |
} | |
errHandler.IsAddedToReport = true; | |
} | |
} | |
} |
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
New Features
IsAddedToReport
in theErrorHandler
class to track error reporting status.Bug Fixes
Style