From b26af85389818c096ec951f0778cece0767a5768 Mon Sep 17 00:00:00 2001 From: JusterZhu Date: Thu, 21 May 2026 03:09:39 +0800 Subject: [PATCH] fix: generate simulation report regardless of success or failure --- src/ViewModels/SimulateViewModel.cs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ViewModels/SimulateViewModel.cs b/src/ViewModels/SimulateViewModel.cs index 2943674..b09d5ea 100644 --- a/src/ViewModels/SimulateViewModel.cs +++ b/src/ViewModels/SimulateViewModel.cs @@ -98,14 +98,24 @@ async Task StartSimulation() if (result.Success) { Status = _loc.T("Sim.Completed", result.Elapsed.TotalSeconds); - L($"Result: {(result.Success ? "PASS" : "FAIL")}"); - foreach (var note in result.Notes) L($" Note: {note}"); - var reportPath = await _report.GenerateAsync(Config, result, Config.OutputDirectory); - L(_loc.T("Sim.Report", reportPath)); } - else { Status = _loc.T("Sim.Failed", result.ErrorMessage ?? "unknown"); } + else + { + Status = _loc.T("Sim.Failed", result.ErrorMessage ?? "unknown"); + } + L($"Result: {(result.Success ? "PASS" : "FAIL")}"); + foreach (var note in result.Notes) L($" Note: {note}"); + var reportPath = await _report.GenerateAsync(Config, result, Config.OutputDirectory); + L(_loc.T("Sim.Report", reportPath)); + } + catch (Exception ex) + { + Status = $"Error: {ex.Message}"; + L($"FATAL: {ex}"); + var failResult = new SimulationResult { Success = false, ErrorMessage = ex.Message }; + var reportPath = await _report.GenerateAsync(Config, failResult, Config.OutputDirectory); + L(_loc.T("Sim.Report", reportPath)); } - catch (Exception ex) { Status = $"Error: {ex.Message}"; L($"FATAL: {ex}"); } finally { IsRunning = false; } }