Added further parsing validation and error messages

This commit is contained in:
David Kartchner
2025-11-07 16:00:47 -07:00
parent 4832df5e15
commit e4798dcf66
+10 -5
View File
@@ -445,14 +445,19 @@ public class Connection
var parsedLogs = await response.Content.ReadFromJsonAsync<List<Dictionary<string, object>>>()
?? throw new UserReportedException("Failed to parse response");
if (parsedLogs.Count < 1)
{
return "Failed to run";
return "No logs available";
}
try
{
var lastLogResultString = ((JsonElement)parsedLogs[0]["Message"]).GetString();
var lastLogResult = JsonSerializer.Deserialize<JsonElement>(lastLogResultString);
return lastLogResult.GetProperty("ParsedResult").ToString();
} catch
{
return "Failed to parse backup log";
}
var lastLogResultString = ((JsonElement)parsedLogs[0]["Message"]).GetString();
var lastLogResult = JsonSerializer.Deserialize<JsonElement>(lastLogResultString);
return lastLogResult.GetProperty("ParsedResult").ToString();
}
/// <summary>