mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-08 07:45:32 +01:00
When raising an exception during exception handling, chain them together for slightly cleaner logs
This commit is contained in:
parent
7488505e37
commit
b70e21a6d5
5 changed files with 31 additions and 15 deletions
|
|
@ -78,10 +78,16 @@ class Consumer(LoggingMixin):
|
|||
{"type": "status_update", "data": payload},
|
||||
)
|
||||
|
||||
def _fail(self, message, log_message=None, exc_info=None):
|
||||
def _fail(
|
||||
self,
|
||||
message,
|
||||
log_message=None,
|
||||
exc_info=None,
|
||||
exception: Optional[Exception] = None,
|
||||
):
|
||||
self._send_progress(100, 100, "FAILED", message)
|
||||
self.log("error", log_message or message, exc_info=exc_info)
|
||||
raise ConsumerError(f"{self.filename}: {log_message or message}")
|
||||
raise ConsumerError(f"{self.filename}: {log_message or message}") from exception
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
|
@ -152,6 +158,7 @@ class Consumer(LoggingMixin):
|
|||
MESSAGE_PRE_CONSUME_SCRIPT_ERROR,
|
||||
f"Error while executing pre-consume script: {e}",
|
||||
exc_info=True,
|
||||
exception=e,
|
||||
)
|
||||
|
||||
def run_post_consume_script(self, document):
|
||||
|
|
@ -217,6 +224,7 @@ class Consumer(LoggingMixin):
|
|||
MESSAGE_POST_CONSUME_SCRIPT_ERROR,
|
||||
f"Error while executing post-consume script: {e}",
|
||||
exc_info=True,
|
||||
exception=e,
|
||||
)
|
||||
|
||||
def try_consume_file(
|
||||
|
|
@ -331,6 +339,7 @@ class Consumer(LoggingMixin):
|
|||
str(e),
|
||||
f"Error while consuming document {self.filename}: {e}",
|
||||
exc_info=True,
|
||||
exception=e,
|
||||
)
|
||||
|
||||
# Prepare the document classifier.
|
||||
|
|
@ -415,6 +424,7 @@ class Consumer(LoggingMixin):
|
|||
f"The following error occurred while consuming "
|
||||
f"{self.filename}: {e}",
|
||||
exc_info=True,
|
||||
exception=e,
|
||||
)
|
||||
finally:
|
||||
document_parser.cleanup()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue