From f6239d6df84718044d26f5e746b08a15afb944bf Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 3 Sep 2007 23:42:17 +0200 Subject: [PATCH] Handle exceptions in the activity constructor so that log messages ends up in the activity log rather than in shell/journal. --- sugar/activity/activityfactoryservice.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sugar/activity/activityfactoryservice.py b/sugar/activity/activityfactoryservice.py index 682abaa0..c10a50df 100644 --- a/sugar/activity/activityfactoryservice.py +++ b/sugar/activity/activityfactoryservice.py @@ -19,6 +19,8 @@ import os import sys from optparse import OptionParser import gettext +import traceback +import logging import gobject import gtk @@ -77,6 +79,7 @@ class ActivityFactoryService(dbus.service.Object): called multiple times for each time start is called!) """ self._activities = [] + self._service_name = service_name splitted_module = activity_class.rsplit('.', 1) module_name = splitted_module[0] @@ -107,7 +110,13 @@ class ActivityFactoryService(dbus.service.Object): returns xid for the created instance' root window """ activity_handle = activityhandle.create_from_dict(handle) - activity = self._constructor(activity_handle) + + try: + activity = self._constructor(activity_handle) + except Exception, e: + logging.error(traceback.format_exc()) + sys.exit(1) + activity.present() self._activities.append(activity)