From 2d7c54ceaeb76976b14402fcd8c7cb3a2330894b Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 3 Aug 2026 10:34:35 +0200 Subject: [PATCH] Refactor JobException message handling Renamed the `Message` method to `CreateMessage` for clarity and updated its usage in the `JobException` constructor. Simplified the error message format by removing visual separator lines, resulting in cleaner and more concise output. --- .../Common/Exceptions/JobException.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ECMJobRunner.Application/Common/Exceptions/JobException.cs b/ECMJobRunner.Application/Common/Exceptions/JobException.cs index 0c89a86..74b0db3 100644 --- a/ECMJobRunner.Application/Common/Exceptions/JobException.cs +++ b/ECMJobRunner.Application/Common/Exceptions/JobException.cs @@ -26,7 +26,7 @@ namespace ECMJobRunner.Application.Common.Exceptions /// public JobException(string jobName, string processName, string batchId, string? reason, Exception? innerException, params (string Name, string? Value, bool IgnoreIfNull)[] details) : base( - Message(jobName, + CreateMessage(jobName, [ ("Process Name", processName, false), ("Batch Id", batchId, false), @@ -65,26 +65,22 @@ namespace ECMJobRunner.Application.Common.Exceptions /// Message format: /// /// {jobName} could not be completed. - /// ───────────────────────────────────────── /// Process Name: {processName} /// Batch Id: {batchId} /// {additional details...} - /// ───────────────────────────────────────── /// /// Details with IgnoreIfNull=true are omitted when their value is null. /// - internal static string Message(string jobName, IEnumerable<(string Name, string? Value, bool IgnoreIfNull)> details) + internal static string CreateMessage(string jobName, IEnumerable<(string Name, string? Value, bool IgnoreIfNull)> details) { var message = new System.Text.StringBuilder(); message.AppendLine($"{jobName} could not be completed."); - message.AppendLine("─────────────────────────────────────────"); foreach (var (name, value, ignoreNullValue) in details) { if (ignoreNullValue && value is null) continue; message.AppendLine($" {name}: {value}"); } - message.AppendLine("─────────────────────────────────────────"); return message.ToString(); } }