version=version, timeout=86400)
except (EOFError, IncompatibleClassifierVersionError) as e:
# there's something wrong with the model file.
- logger.error(
+ logger.exception(
f"Unrecoverable error while loading document "
- f"classification model: {str(e)}, deleting model file."
+ f"classification model, deleting model file."
)
os.unlink(settings.MODEL_FILE)
classifier = None
try:
if exists_in(settings.INDEX_DIR) and not recreate:
return open_dir(settings.INDEX_DIR, schema=get_schema())
- except Exception as e:
- logger.error(f"Error while opening the index: {e}, recreating.")
+ except Exception:
+ logger.exception(f"Error while opening the index, recreating.")
if not os.path.isdir(settings.INDEX_DIR):
os.makedirs(settings.INDEX_DIR, exist_ok=True)
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()
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",
# 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):
try:
total_new_documents += MailAccountHandler().handle_mail_account(
account)
- except MailError as e:
- logger.error(
- f"Error while processing mail account {account}: {e}",
- exc_info=True
- )
+ except MailError:
+ logger.exception(f"Error while processing mail account {account}")
if total_new_documents > 0:
return f"Added {total_new_documents} document(s)."