[GTKUI] Improve error handling in torrent details

If status is missing a key required for a widget a KeyError
was not always caught.
This commit is contained in:
bendikro 2016-02-19 15:47:27 +01:00 committed by Calum Lind
parent 712b2715d4
commit eda493e525
1 changed files with 7 additions and 8 deletions

View File

@ -46,16 +46,15 @@ class Tab(object):
return self._tab_label
def get_status_for_widget(self, widget, status):
if widget[1] is None:
txt = status[widget[2][0]]
else:
try:
args = [status[key] for key in widget[2]]
except KeyError as ex:
log.debug("Unable to get status value: %s", ex)
txt = ""
try:
if widget[1] is None:
txt = status[widget[2][0]]
else:
args = [status[key] for key in widget[2]]
txt = widget[1](*args)
except KeyError as ex:
log.warn("Unable to get status value: %s", ex)
txt = ""
return txt