Show office exception instead of crash

This commit is contained in:
ema
2025-06-12 15:31:28 +08:00
parent e2e5885fd5
commit f897ce46ea
3 changed files with 17 additions and 11 deletions

View File

@@ -134,11 +134,22 @@ public class Plugin : IViewer
}
}
_panel = new PreviewPanel();
context.ViewerContent = _panel;
context.Title = Path.GetFileName(path);
_panel.PreviewFile(path, context);
try
{
_panel = new PreviewPanel();
context.ViewerContent = _panel;
context.Title = Path.GetFileName(path);
_panel.PreviewFile(path, context);
}
catch (Exception e)
{
context.ViewerContent = new Label()
{
Content = e.ToString(),
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
};
}
context.IsBusy = false;
}