Refactor incident creation to include NodeId and remove duplication

Replaced `activity.Id` with `activity.NodeId` in incident creation for enhanced context. Removed redundant `LogExceptionAndTransition` method by consolidating logic into existing workflow, reducing duplication and improving maintainability.
This commit is contained in:
Sipke Schoorstra 2025-04-11 21:17:41 +02:00
parent 4266421a4c
commit 2ce5bbfbf1
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
2 changed files with 1 additions and 12 deletions

View file

@ -318,7 +318,7 @@ public static partial class ActivityExecutionContextExtensions
var exceptionState = ExceptionState.FromException(e);
var systemClock = context.GetRequiredService<ISystemClock>();
var now = systemClock.UtcNow;
var incident = new ActivityIncident(activity.Id, activity.Type, e.Message, exceptionState, now);
var incident = new ActivityIncident(activity.Id, activity.NodeId, activity.Type, e.Message, exceptionState, now);
context.WorkflowExecutionContext.Incidents.Add(incident);
context.AggregateFaultCount++;

View file

@ -37,17 +37,6 @@ public class ExceptionHandlingMiddleware(ActivityMiddlewareDelegate next, IIncid
}
}
private void LogExceptionAndTransition(ActivityExecutionContext context, Exception e)
{
context.Exception = e;
context.TransitionTo(ActivityStatus.Faulted);
var activity = context.Activity;
var exceptionState = ExceptionState.FromException(e);
var now = systemClock.UtcNow;
var incident = new ActivityIncident(activity.Id, activity.NodeId ,activity.Type, e.Message, exceptionState, now);
context.WorkflowExecutionContext.Incidents.Add(incident);
}
private async Task HandleIncidentAsync(ActivityExecutionContext context)
{
var strategy = await incidentStrategyResolver.ResolveStrategyAsync(context);