Give more descriptive errors when custom notification parameters fail.

This commit is contained in:
Tim 2015-08-05 00:13:47 +02:00
parent f80429ef7a
commit fa782641ef

View file

@ -273,13 +273,17 @@ def build_notify_text(session, state):
if on_start_subject and on_start_body: if on_start_subject and on_start_body:
try: try:
subject_text = on_start_subject.format(**available_params) subject_text = on_start_subject.format(**available_params)
except LookupError, e:
logger.error(u"PlexPy Notifier :: Unable to parse field %s in notification subject. Using fallback." % e)
except: except:
logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using default.") logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using fallback.")
try: try:
body_text = on_start_body.format(**available_params) body_text = on_start_body.format(**available_params)
except LookupError, e:
logger.error(u"PlexPy Notifier :: Unable to parse field %s in notification body. Using fallback." % e)
except: except:
logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using default.") logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using fallback.")
return [subject_text, body_text] return [subject_text, body_text]
else: else:
@ -293,13 +297,17 @@ def build_notify_text(session, state):
if on_stop_subject and on_stop_body: if on_stop_subject and on_stop_body:
try: try:
subject_text = on_stop_subject.format(**available_params) subject_text = on_stop_subject.format(**available_params)
except LookupError, e:
logger.error(u"PlexPy Notifier :: Unable to parse field %s in notification subject. Using fallback." % e)
except: except:
logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using default.") logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using fallback.")
try: try:
body_text = on_stop_body.format(**available_params) body_text = on_stop_body.format(**available_params)
except LookupError, e:
logger.error(u"PlexPy Notifier :: Unable to parse field %s in notification body. Using fallback." % e)
except: except:
logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using default.") logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using fallback.")
return [subject_text, body_text] return [subject_text, body_text]
else: else:
@ -313,13 +321,17 @@ def build_notify_text(session, state):
if on_watched_subject and on_watched_body: if on_watched_subject and on_watched_body:
try: try:
subject_text = on_watched_subject.format(**available_params) subject_text = on_watched_subject.format(**available_params)
except LookupError, e:
logger.error(u"PlexPy Notifier :: Unable to parse field %s in notification subject. Using fallback." % e)
except: except:
logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using default.") logger.error(u"PlexPy Notifier :: Unable to parse custom notification subject. Using fallback.")
try: try:
body_text = on_watched_body.format(**available_params) body_text = on_watched_body.format(**available_params)
except LookupError, e:
logger.error(u"PlexPy Notifier :: Unable to parse field %s in notification body. Using fallback." % e)
except: except:
logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using default.") logger.error(u"PlexPy Notifier :: Unable to parse custom notification body. Using fallback.")
return [subject_text, body_text] return [subject_text, body_text]
else: else: