diff --git a/ChainSharp.Tests.Integration/IntegrationTests/WorkflowTests.cs b/ChainSharp.Tests.Integration/IntegrationTests/WorkflowTests.cs index 3d7e94f..f1072b3 100644 --- a/ChainSharp.Tests.Integration/IntegrationTests/WorkflowTests.cs +++ b/ChainSharp.Tests.Integration/IntegrationTests/WorkflowTests.cs @@ -319,7 +319,7 @@ public async Task TestChainWithShortCircuitStaysLeft() workflow.Memory.Should().NotBeNull(); result.Should().NotBeNull(); } - + [Theory] public async Task TestWithException() { @@ -331,11 +331,11 @@ public async Task TestWithException() Assert.ThrowsAsync(async () => await workflow.Run(Unit.Default)); } - + private class ThrowsStep : Step { - public override Task Run(Unit input) - => throw new WorkflowException("This is a workflow exception."); + public override Task Run(Unit input) => + throw new WorkflowException("This is a workflow exception."); } private class OuterProperty @@ -635,13 +635,10 @@ Ingredients input .Resolve(); } } - - private class ChainTestWithException - : Workflow + + private class ChainTestWithException : Workflow { - protected override async Task> RunInternal(Unit input) - => Activate(input) - .Chain() - .Resolve(); + protected override async Task> RunInternal(Unit input) => + Activate(input).Chain().Resolve(); } } diff --git a/ChainSharp/Step/Step.cs b/ChainSharp/Step/Step.cs index 78d1da8..1b249c3 100644 --- a/ChainSharp/Step/Step.cs +++ b/ChainSharp/Step/Step.cs @@ -21,11 +21,17 @@ public async Task> RailwayStep(Either pr } catch (Exception e) { - var messageField = typeof(Exception).GetField("_message", BindingFlags.Instance | BindingFlags.NonPublic); - + var messageField = typeof(Exception).GetField( + "_message", + BindingFlags.Instance | BindingFlags.NonPublic + ); + if (messageField != null) - messageField.SetValue(e, $"{{ \"Step\": \"{GetType().Name}\", \"Type\": \"{e.GetType().Name}\", \"Message\": \"{e.Message}\" }}"); - + messageField.SetValue( + e, + $"{{ \"Step\": \"{GetType().Name}\", \"Type\": \"{e.GetType().Name}\", \"Message\": \"{e.Message}\" }}" + ); + Console.WriteLine($"Step: ({GetType().Name}) failed with Exception: ({e.Message})"); return e; }