Return-Path: Delivered-To: apmail-gump-commits-archive@www.apache.org Received: (qmail 71130 invoked from network); 7 Jan 2005 19:46:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Jan 2005 19:46:42 -0000 Received: (qmail 5782 invoked by uid 500); 7 Jan 2005 19:46:42 -0000 Mailing-List: contact commits-help@gump.apache.org; run by ezmlm Precedence: bulk Reply-To: commits@gump.apache.org List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@gump.apache.org Received: (qmail 5765 invoked by uid 99); 7 Jan 2005 19:46:42 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 07 Jan 2005 11:46:41 -0800 Received: (qmail 71104 invoked by uid 65534); 7 Jan 2005 19:46:40 -0000 Date: 7 Jan 2005 19:46:40 -0000 Message-ID: <20050107194640.71102.qmail@minotaur.apache.org> From: leosimons@apache.org To: commits@gump.apache.org Subject: svn commit: r124567 - /gump/branches/Gump3/pygump/python/gump/plugins/__init__.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: leosimons Date: Fri Jan 7 11:46:40 2005 New Revision: 124567 URL: http://svn.apache.org/viewcvs?view=rev&rev=124567 Log: Fix more error handling bugs. Still a mess. Figure out right way to do this. 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&rev=124567&p1=gump/branches/Gump3/pygump/python/gump/plugins/__init__.py&r1=124566&p2=gump/branches/Gump3/pygump/python/gump/plugins/__init__.py&r2=124567 ============================================================================== --- gump/branches/Gump3/pygump/python/gump/plugins/__init__.py (original) +++ gump/branches/Gump3/pygump/python/gump/plugins/__init__.py Fri Jan 7 11:46:40 2005 @@ -19,15 +19,16 @@ __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation" __license__ = "http://www.apache.org/licenses/LICENSE-2.0" +import sys + class BaseErrorHandler: """Base error handler for use with the MulticastPlugin. This handler just re-raises a caught error. """ - def handle(self, visitor, visited_model_object): + def handle(self, visitor, visited_model_object, type, value, traceback): """Override this method to be able to swallow exceptions.""" - import sys - (type, value, traceback) = sys.exc_info() + # TODO this is not properly saving the traceback stack. Highly annoying. Fix it! raise type, value class LoggingErrorHandler: @@ -38,11 +39,9 @@ def __init__(self, log): self.log = log - def handle(self, visitor, visited_model_object): + 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)) - import sys - (type, value, traceback) = sys.exc_info() raise type, value class AbstractPlugin: @@ -115,32 +114,44 @@ def initialize(self): for visitor in self.list: try: visitor._initialize() - except: self.error_handler.handle(visitor, "{{{initialization stage}}}") + except: + (type, value, traceback) = sys.exc_info() + self.error_handler.handle(visitor, "{{{initialization stage}}}", type, value, traceback) def visit_workspace(self, workspace): for visitor in self.list: try: visitor._visit_workspace(workspace) - except: self.error_handler.handle(visitor, workspace) + except: + (type, value, traceback) = sys.exc_info() + self.error_handler.handle(visitor, workspace, type, value, traceback) def visit_repository(self, repository): for visitor in self.list: try: visitor._visit_repository(repository) - except: self.error_handler.handle(visitor, repository) + except: + (type, value, traceback) = sys.exc_info() + self.error_handler.handle(visitor, repository, type, value, traceback) def visit_module(self, module): for visitor in self.list: try: visitor._visit_module(module) - except: self.error_handler.handle(visitor, module) + except: + (type, value, traceback) = sys.exc_info() + self.error_handler.handle(visitor, module, type, value, traceback) def visit_project(self, project): for visitor in self.list: try: visitor._visit_project(project) - except: self.error_handler.handle(visitor, project) + except: + (type, value, traceback) = sys.exc_info() + self.error_handler.handle(visitor, project, type, value, traceback) def finalize(self): for visitor in self.list: try: visitor._finalize() - except: self.error_handler.handle(visitor, "{{{finalization stage}}}") + except: + (type, value, traceback) = sys.exc_info() + self.error_handler.handle(visitor, "{{{finalization stage}}}", type, value, traceback) class LoggingPlugin(AbstractPlugin): """Plugin that prints debug messages as it visits model objects."""