From 756a8ed08926c338d1ab19973ad07c390ad8639c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Milewski?= Date: Thu, 31 Oct 2024 16:05:54 +0100 Subject: [PATCH] Small check --- .../Interfaces/IEventInspectionContext.cs | 1 - .../Classes/StateMachineInterceptor.cs | 34 +++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Core/Stateflows/StateMachines/Inspection/Interfaces/IEventInspectionContext.cs b/Core/Stateflows/StateMachines/Inspection/Interfaces/IEventInspectionContext.cs index 3d1d16b..5acf7c9 100644 --- a/Core/Stateflows/StateMachines/Inspection/Interfaces/IEventInspectionContext.cs +++ b/Core/Stateflows/StateMachines/Inspection/Interfaces/IEventInspectionContext.cs @@ -1,5 +1,4 @@ using Stateflows.Common; -using Stateflows.Common.Context; using Stateflows.StateMachines.Context.Interfaces; namespace Stateflows.StateMachines.Inspection.Interfaces diff --git a/Extensions/Stateflows.Extensions.PlantUml/Classes/StateMachineInterceptor.cs b/Extensions/Stateflows.Extensions.PlantUml/Classes/StateMachineInterceptor.cs index 8732a30..6d340a1 100644 --- a/Extensions/Stateflows.Extensions.PlantUml/Classes/StateMachineInterceptor.cs +++ b/Extensions/Stateflows.Extensions.PlantUml/Classes/StateMachineInterceptor.cs @@ -1,9 +1,11 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Stateflows.Common; using Stateflows.StateMachines; using Stateflows.StateMachines.Context.Interfaces; using Stateflows.StateMachines.Inspection.Interfaces; using Stateflows.Extensions.PlantUml.Events; +using System.Diagnostics; namespace Stateflows.Extensions.PlantUml.Classes { @@ -14,17 +16,27 @@ public Task AfterHydrateAsync(IStateMachineActionContext context) public Task AfterProcessEventAsync(IEventActionContext context) { - if ( - context is IEventInspectionContext inspectionContext && - inspectionContext.StateMachine.Inspection.StateHasChanged - ) + try { - context.StateMachine.Publish( - new PlantUmlNotification() - { - PlantUml = inspectionContext.StateMachine.Inspection.GetPlantUml() - } - ); + if (context is IEventInspectionContext inspectionContext && + inspectionContext.StateMachine.Inspection.StateHasChanged + ) + { + context.StateMachine.Publish( + new PlantUmlNotification() + { + PlantUml = inspectionContext.StateMachine.Inspection.GetPlantUml() + } + ); + } + } + catch (Exception e) + { + Trace.WriteLine($"⦗→s⦘ PlantUML exception '{e.GetType().Name}' thrown with message '{e.Message}'; stack trace:"); + foreach (var line in e.StackTrace.Split('\n')) + { + Trace.WriteLine($"⦗→s⦘ {line}"); + } } return Task.CompletedTask;