Improve error handling in Microsoft Word export

This commit is contained in:
Thorsten Sommer 2025-12-10 16:43:26 +01:00
parent f521c11a60
commit 88c1e3d434
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 12 additions and 3 deletions

View File

@ -80,11 +80,18 @@ public static class PandocExport
return false;
}
// Read output streams asynchronously while the process runs (prevents deadlock):
var outputTask = process.StandardOutput.ReadToEndAsync();
var errorTask = process.StandardError.ReadToEndAsync();
// Wait for the process to exit AND for streams to be fully read:
await process.WaitForExitAsync();
await outputTask;
var error = await errorTask;
if (process.ExitCode is not 0)
{
var error = await process.StandardError.ReadToEndAsync();
LOGGER.LogError($"Pandoc failed with exit code {process.ExitCode}: {error}");
LOGGER.LogError("Pandoc failed with exit code {ProcessExitCode}: '{ErrorText}'", process.ExitCode, error);
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Cancel, TB("Error during Microsoft Word export")));
return false;
}

View File

@ -6,4 +6,6 @@
- Improved the document preview dialog for the document analysis assistant (in preview), providing Markdown and plain text views for attached files.
- Improved the ID handling for configuration plugins.
- Improved error handling, logging, and code quality.
- Fixed a bug in the local data sources info dialog (preview feature) for data directories that could cause the app to crash. The error was caused by a background thread producing data while the frontend attempted to display it.
- Improved error handling for Microsoft Word export.
- Fixed a bug in the local data sources info dialog (preview feature) for data directories that could cause the app to crash. The error was caused by a background thread producing data while the frontend attempted to display it.
- Fixed a rare bug in the Microsoft Word export for huge documents.