Browse Source

Do not crash if we cannot format the error message

pull/1673/head
Safihre 5 years ago
parent
commit
2714ffe04d
  1. 8
      SABnzbd.py

8
SABnzbd.py

@ -127,11 +127,17 @@ class GUIHandler(logging.Handler):
def emit(self, record: logging.LogRecord): def emit(self, record: logging.LogRecord):
""" Emit a record by adding it to our private queue """ """ Emit a record by adding it to our private queue """
parsed_msg = record.msg % record.args # If % is part of the msg, this could fail
try:
parsed_msg = record.msg % record.args
except TypeError:
parsed_msg = record.msg + str(record.args)
if record.levelno == logging.WARNING: if record.levelno == logging.WARNING:
sabnzbd.notifier.send_notification(T("Warning"), parsed_msg, "warning") sabnzbd.notifier.send_notification(T("Warning"), parsed_msg, "warning")
else: else:
sabnzbd.notifier.send_notification(T("Error"), parsed_msg, "error") sabnzbd.notifier.send_notification(T("Error"), parsed_msg, "error")
# Append traceback, if available # Append traceback, if available
warning = {"type": record.levelname, "text": parsed_msg, "time": int(time.time())} warning = {"type": record.levelname, "text": parsed_msg, "time": int(time.time())}
if record.exc_info: if record.exc_info:

Loading…
Cancel
Save