You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by le...@apache.org on 2005/04/17 17:47:59 UTC
svn commit: r161663 -
gump/branches/Gump3/pygump/python/gump/plugins/__init__.py
Author: leosimons
Date: Sun Apr 17 08:47:58 2005
New Revision: 161663
URL: http://svn.apache.org/viewcvs?view=rev&rev=161663
Log:
Create a new error handler which swallows exceptions.
* pygump/python/gump/plugins/__init__.py: new OptimisticLoggingErrorHandler that does not re-raise exceptions but rather stores them as part of the relevant model element. This enables processing to continue in the case of malfunctioning plugins, but is a rather 'crude' setup mostly useful for debugging.
Modified:
gump/branches/Gump3/pygump/python/gump/plugins/__init__.py
Modified: gump/branches/Gump3/pygump/python/gump/plugins/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/__init__.py?view=diff&r1=161662&r2=161663
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/__init__.py Sun Apr 17 08:47:58 2005
@@ -26,6 +26,8 @@
import sys
+from gump.model import ModelObject
+
class BaseErrorHandler:
"""Base error handler for use with the MulticastPlugin.
@@ -48,6 +50,22 @@
"""Override this method to be able to swallow exceptions."""
self.log.exception("%s threw an exception while visiting %s!" % (visitor, visited_model_object))
raise type, value
+
+class OptimisticLoggingErrorHandler:
+ """Logging error handler for use with the MulticastPlugin.
+
+ This handler logs a caught error then stores it on the model.
+ """
+ def __init__(self, log):
+ self.log = log
+
+ def handle(self, visitor, visited_model_object, type, value, traceback):
+ """Override this method to be able to swallow exceptions."""
+ self.log.exception("%s threw an exception while visiting %s!" % (visitor, visited_model_object))
+ if isinstance(visited_model_object, ModelObject):
+ if not hasattr(visited_model_object, 'exceptions'):
+ visited_model_object.exceptions = []
+ visited_model_object.exceptions.append( (type, value, traceback) )
class AbstractPlugin:
"""Base class for all plugins.