better exception logging

This commit is contained in:
jonaswinkler
2021-02-11 22:16:41 +01:00
parent b90a5f625a
commit 555e37958f
5 changed files with 9 additions and 14 deletions

View File

@@ -60,7 +60,7 @@ def handle_document(document_id):
index.update_document(writer, document)
except Exception as e:
logger.error(f"Error while parsing document {document}: {str(e)}")
logger.exception(f"Error while parsing document {document}")
finally:
parser.cleanup()

View File

@@ -54,8 +54,7 @@ def _consume(filepath):
if settings.CONSUMER_SUBDIRS_AS_TAGS:
tag_ids = _tags_from_path(filepath)
except Exception as e:
logger.error(
"Error creating tags from path: {}".format(e))
logger.exception("Error creating tags from path")
try:
async_task("documents.tasks.consume_file",
@@ -66,8 +65,7 @@ def _consume(filepath):
# Catch all so that the consumer won't crash.
# This is also what the test case is listening for to check for
# errors.
logger.error(
"Error while consuming document: {}".format(e))
logger.exception("Error while consuming document")
def _consume_wait_unmodified(file, num_tries=20, wait_time=1):