From d53e8b8dc1371bbb1266cfa00aba940e2cd3fb32 Mon Sep 17 00:00:00 2001 From: lumin Date: Fri, 20 Dec 2024 03:28:15 +0900 Subject: [PATCH] fix: improve error handling in DocConverter Enhance the exception handling in the DocConverter class to provide more informative error messages. Instead of returning None on failure, the code now returns a DocumentConverterResult object that includes the error message, making it easier to diagnose issues when processing DOC files. --- src/markitdown/_markitdown.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/markitdown/_markitdown.py b/src/markitdown/_markitdown.py index 8fafdd1..0470dae 100644 --- a/src/markitdown/_markitdown.py +++ b/src/markitdown/_markitdown.py @@ -749,8 +749,11 @@ def convert(self, local_path, **kwargs) -> Union[None, DocumentConverterResult]: result = self._convert(output_content) return result - except Exception as _: - return None + except Exception as e: + return DocumentConverterResult( + title=None, + text_content=f"[ERROR] Failed to process DOC file {local_path}: {str(e)}", + ) class XlsxConverter(HtmlConverter):