Skip to content

Commit

Permalink
fix: improve error handling in DocConverter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
l-lumin authored and gitbutler-client committed Dec 19, 2024
1 parent 375f88d commit d53e8b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/markitdown/_markitdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d53e8b8

Please sign in to comment.