A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
better exception logging
jonaswinklerfda2bfbea7ce
diff --git a/src/documents/consumer.py b/src/documents/consumer.pyindex 3fd62fabc..3d7d98198 100755--- a/src/documents/consumer.py+++ b/src/documents/consumer.py@@ -64,9 +64,9 @@ class Consumer(LoggingMixin):{'type': 'status_update','data': payload})- def _fail(self, message, log_message=None):+ def _fail(self, message, log_message=None, exc_info=None):self._send_progress(100, 100, 'FAILED', message)- self.log("error", log_message or message)+ self.log("error", log_message or message, exc_info=exc_info)raise ConsumerError(f"{self.filename}: {log_message or message}")def __init__(self):@@ -120,7 +120,8 @@ class Consumer(LoggingMixin):except Exception as e:self._fail(MESSAGE_PRE_CONSUME_SCRIPT_ERROR,- f"Error while executing pre-consume script: {e}"+ f"Error while executing pre-consume script: {e}",+ exc_info=True)def run_post_consume_script(self, document):@@ -150,7 +151,8 @@ class Consumer(LoggingMixin):except Exception as e:self._fail(MESSAGE_POST_CONSUME_SCRIPT_ERROR,- f"Error while executing post-consume script: {e}"+ f"Error while executing post-consume script: {e}",+ exc_info=True)def try_consume_file(self,@@ -255,7 +257,8 @@ class Consumer(LoggingMixin):document_parser.cleanup()self._fail(str(e),- f"Error while consuming document {self.filename}: {e}"+ f"Error while consuming document {self.filename}: {e}",+ exc_info=True)# Prepare the document classifier.@@ -326,7 +329,8 @@ class Consumer(LoggingMixin):self._fail(str(e),f"The following error occured while consuming "- f"{self.filename}: {e}"+ f"{self.filename}: {e}",+ exc_info=True)finally:document_parser.cleanup()diff --git a/src/paperless_tesseract/parsers.py b/src/paperless_tesseract/parsers.pyindex 944bda601..d381ed94f 100644--- a/src/paperless_tesseract/parsers.py+++ b/src/paperless_tesseract/parsers.py@@ -246,9 +246,9 @@ class RasterisedDocumentParser(DocumentParser):if original_has_text:self.text = text_originalexcept (NoTextFoundException, InputFileError) as e:- self.log("exception",- f"Encountered the following error while running OCR, "- f"attempting force OCR to get the text.")+ self.log("warning",+ f"Encountered an error while running OCR: {str(e)}. "+ f"Attempting force OCR to get the text.")archive_path_fallback = os.path.join(self.tempdir, "archive-fallback.pdf")