Added error handling and logging

This commit is contained in:
Thorsten Sommer 2025-12-08 21:10:53 +01:00
parent d1a0fd23ec
commit 18f3b42106
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -33,10 +33,21 @@ public partial class DocumentCheckDialog : MSGComponentBase
{
if (firstRender && !string.IsNullOrWhiteSpace(this.FilePath))
{
var fileContent = await UserFile.LoadFileData(this.FilePath, this.RustService, this.DialogService);
this.FileContent = fileContent;
this.StateHasChanged();
try
{
var fileContent = await UserFile.LoadFileData(this.FilePath, this.RustService, this.DialogService);
this.FileContent = fileContent;
this.StateHasChanged();
}
catch (Exception ex)
{
this.Logger.LogError(ex, "Failed to load file content from '{FilePath}'", this.FilePath);
this.FileContent = string.Empty;
this.StateHasChanged();
}
}
else if (firstRender)
this.Logger.LogWarning("Document check dialog opened without a valid file path");
}
private CodeBlockTheme CodeColorPalette => this.SettingsManager.IsDarkMode ? CodeBlockTheme.Dark : CodeBlockTheme.Default;