[Zope3-checkins] CVS: Zope3/src/zope/app/publication - zopepublication.py:1.19

Jim Fulton jim@zope.com
Thu, 6 Mar 2003 17:11:30 -0500


Update of /cvs-repository/Zope3/src/zope/app/publication
In directory cvs.zope.org:/tmp/cvs-serv8241

Modified Files:
	zopepublication.py 
Log Message:
Added logic to log errors raised when calling error views to the error
reporting service so they can be debugged.

To do this sanely, factored logic to log to the error reporting
service into a separate method.


=== Zope3/src/zope/app/publication/zopepublication.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/publication/zopepublication.py:1.18	Sun Mar  2 10:08:50 2003
+++ Zope3/src/zope/app/publication/zopepublication.py	Thu Mar  6 17:11:30 2003
@@ -164,22 +164,8 @@
         txn.setUser(request.user.getId())
         get_transaction().commit()
 
-    def handleException(self, object, request, exc_info, retry_allowed=True):
-        # This transaction had an exception that reached the publisher.
-        # It must definitely be aborted.
-        get_transaction().abort()
-
-        # Convert ConflictErrors to Retry exceptions.
-        if retry_allowed and isinstance(exc_info[1], ConflictError):
-            tryToLogWarning('ZopePublication',
-                'Competing writes/reads at %s' % 
-                request.get('PATH_INFO', '???'),
-                exc_info=True)
-            raise Retry
-        # Are there any reasons why we'd want to let application-level error
-        # handling determine whether a retry is allowed or not?
-        # Assume not for now.
 
+    def _logErrorWithErrorReportingService(self, object, request, exc_info):
         # Record the error with the ErrorReportingService
         beginErrorHandlingTransaction(request, 'error reporting service')
         try:
@@ -206,6 +192,27 @@
                 ErrorReports)
             get_transaction().abort()
 
+        
+
+    def handleException(self, object, request, exc_info, retry_allowed=True):
+        # This transaction had an exception that reached the publisher.
+        # It must definitely be aborted.
+        get_transaction().abort()
+
+        # Convert ConflictErrors to Retry exceptions.
+        if retry_allowed and isinstance(exc_info[1], ConflictError):
+            tryToLogWarning('ZopePublication',
+                'Competing writes/reads at %s' % 
+                request.get('PATH_INFO', '???'),
+                exc_info=True)
+            raise Retry
+        # Are there any reasons why we'd want to let application-level error
+        # handling determine whether a retry is allowed or not?
+        # Assume not for now.
+
+        # Record the error with the ErrorReportingService
+        self._logErrorWithErrorReportingService(object, request, exc_info)
+
         response = request.response
         exception = None
         legacy_exception = not isinstance(exc_info[1], Exception)
@@ -246,6 +253,11 @@
                     # Log an error.
                     tryToLogException(
                         'Exception while rendering view on exception')
+
+                    # Record the error with the ErrorReportingService
+                    self._logErrorWithErrorReportingService(
+                        object, request, sys.exc_info())
+
                     view = None
 
             if view is None: