From a10b76458e1988532c1459d7dcc8d6f822215539 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Tue, 5 Mar 2013 15:46:58 +0100 Subject: handle user-methods exceptions nicely --- py3status/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/py3status/__init__.py b/py3status/__init__.py index f01c306..9833bf8 100644 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -162,8 +162,12 @@ def inject(j): raise KeyError, 'cache timeout' except KeyError: # execute the method - meth = getattr(my_class, my_method) - index, result = meth(j, I3STATUS_CONFIG) + try: + meth = getattr(my_class, my_method) + index, result = meth(j, I3STATUS_CONFIG) + except Exception, err: + syslog(LOG_ERR, "user method %s failed (%s)" % (my_method, str(err))) + index, result = (0, {'name': '', 'full_text': ''}) # respect user-defined cache timeout for this module if not result.has_key('cached_until'): -- cgit v1.3