logging: Use logging.exception and exc_info for unexpected exceptions.

logging.exception() and logging.debug(exc_info=True),
etc. automatically include a traceback.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-06-11 16:35:37 -07:00
committed by Tim Abbott
parent 4b6d2cf25f
commit 1ed2d9b4a0
20 changed files with 71 additions and 58 deletions

View File

@@ -408,12 +408,11 @@ def process_message(message: EmailMessage, rcpt_to: Optional[str]=None) -> None:
process_missed_message(to, message)
else:
process_stream_message(to, message)
except ZulipEmailForwardUserError as e:
# TODO: notify sender of error, retry if appropriate.
logging.warning(e.args[0])
except ZulipEmailForwardError as e:
if isinstance(e, ZulipEmailForwardUserError):
# TODO: notify sender of error, retry if appropriate.
logging.warning(str(e))
else:
log_and_report(message, str(e), to)
log_and_report(message, e.args[0], to)
def validate_to_address(rcpt_to: str) -> None:
if is_missed_message_address(rcpt_to):