From 13d2233edcb96a59ac180e6d15c6670384133fa5 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 8 Sep 2025 20:22:49 +0200 Subject: Fixes --- LibSystemdCli/SystemdExecutor.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'LibSystemdCli/SystemdExecutor.cs') diff --git a/LibSystemdCli/SystemdExecutor.cs b/LibSystemdCli/SystemdExecutor.cs index ead11fd..f252891 100644 --- a/LibSystemdCli/SystemdExecutor.cs +++ b/LibSystemdCli/SystemdExecutor.cs @@ -8,7 +8,15 @@ public class SystemdExecutor { public static async IAsyncEnumerable GetUnits() { var output = await CommandExecutor.ExecuteCommand("systemctl", "list-units --all --no-legend --no-pager --no-legend -o json-pretty"); - var data = JsonSerializer.Deserialize>(output); + List? data; + try { + data = JsonSerializer.Deserialize>(output); + } + catch (Exception ex) { + Console.WriteLine("Failed to parse systemctl output: " + ex); + Console.WriteLine("Output was: " + output); + yield break; + } foreach (var unit in data) { try { @@ -16,7 +24,9 @@ public class SystemdExecutor { // Console.WriteLine(fragmentOutput); unit.FragmentPaths = fragmentOutput.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList(); } - catch { } + catch (Exception e) { + Console.WriteLine("Failed to get fragment path for unit " + unit.Unit + ": " + e); + } yield return unit; // await Task.Delay(100); -- cgit 1.5.1