Skip to content

Commit 3902e76

Browse files
authored
Error string message (#261)
* Error string message * Update ReleaseNotes.md * Formatting Markdown --------- Co-authored-by: Tom Longhurst <thomhurst@users.noreply.github.com>
1 parent 1d239ba commit 3902e76

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

src/ModularPipelines.Build/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@ await PipelineHostBuilder.Create()
6666
.AddModule<UpdateReleaseNotesModule>();
6767
}
6868
})
69+
.ConfigurePipelineOptions((context, options) => options.DefaultRetryCount = 3)
6970
.ExecutePipelineAsync();
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* Chocolatey CLI helpers
2+
* Not in parallel attribute for running modules without parallelisation
23

34
<!---->
45

5-
* Not in parallel attribute for running modules without parallelisation
6+
* Better display of errored modules in the console output

src/ModularPipelines/Engine/Executors/ModuleHandlers/ErrorHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ private async Task CancelPipelineAndThrow(Exception exception)
7979
await Task.Delay(TimeSpan.FromMilliseconds(200));
8080

8181
ModuleResultTaskCompletionSource.TrySetException(exception);
82+
83+
Context.Logger.SetException(exception);
8284

8385
throw new ModuleFailedException(Module, exception);
8486
}

src/ModularPipelines/Logging/IModuleLogger.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
namespace ModularPipelines.Logging;
44

5-
public interface IModuleLogger : ILogger, IDisposable, IConsoleWriter;
5+
public interface IModuleLogger : ILogger, IDisposable, IConsoleWriter
6+
{
7+
internal void SetException(Exception exception);
8+
}

src/ModularPipelines/Logging/ModuleLogger.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace ModularPipelines.Logging;
88
internal abstract class ModuleLogger : IModuleLogger
99
{
1010
protected static readonly object Lock = new();
11+
protected Exception? _exception;
1112

1213
internal DateTime LastLogWritten { get; set; } = DateTime.MinValue;
1314

@@ -20,6 +21,11 @@ internal abstract class ModuleLogger : IModuleLogger
2021
public abstract void Dispose();
2122

2223
public abstract void LogToConsole(string value);
24+
25+
public void SetException(Exception exception)
26+
{
27+
_exception = exception;
28+
}
2329
}
2430

2531
internal class ModuleLogger<T> : ModuleLogger, IModuleLogger, ILogger<T>
@@ -203,6 +209,11 @@ private void TryObfuscateValues(object state)
203209

204210
private string GetCollapsibleSectionName()
205211
{
212+
if (_exception != null)
213+
{
214+
return $"{typeof(T).Name} - Error! {_exception.GetType().Name}";
215+
}
216+
206217
return $"{typeof(T).Name}";
207218
}
208219

test/ModularPipelines.UnitTests/NotInParallelTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async Task NotInParallel()
7272
Assert.That(
7373
nextModule.StartTime.ToUnixTimeMilliseconds(),
7474
Is.EqualTo((firstModule.StartTime + TimeSpan.FromSeconds(1)).ToUnixTimeMilliseconds())
75-
.Within(150)
75+
.Within(250)
7676
);
7777
}
7878

@@ -90,7 +90,7 @@ public async Task NotInParallel_With_ParallelDependency()
9090
Assert.That(
9191
nextModule.StartTime.ToUnixTimeMilliseconds(),
9292
Is.EqualTo((firstModule.StartTime + TimeSpan.FromSeconds(1)).ToUnixTimeMilliseconds())
93-
.Within(150)
93+
.Within(250)
9494
);
9595
}
9696

@@ -109,7 +109,7 @@ public async Task NotInParallel_With_NonParallelDependency()
109109
Assert.That(
110110
nextModule.StartTime.ToUnixTimeMilliseconds(),
111111
Is.EqualTo((firstModule.StartTime + TimeSpan.FromSeconds(2)).ToUnixTimeMilliseconds())
112-
.Within(150)
112+
.Within(250)
113113
);
114114
}
115115
}

0 commit comments

Comments
 (0)