[Zope-Checkins] CVS: Zope3/lib/python/Zope/Server/LineReceiver - LineServerChannel.py:1.1.2.6 LineTask.py:1.1.2.3

Shane Hathaway shane@cvs.zope.org
Mon, 8 Apr 2002 16:19:19 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Server/LineReceiver
In directory cvs.zope.org:/tmp/cvs-serv10982

Modified Files:
      Tag: Zope3-Server-Branch
	LineServerChannel.py LineTask.py 
Log Message:
More exception handling


=== Zope3/lib/python/Zope/Server/LineReceiver/LineServerChannel.py 1.1.2.5 => 1.1.2.6 ===
 import stat
 import socket
+import sys
 import time
 
 from Zope.Server.ServerChannelBase import ServerChannelBase
@@ -60,6 +61,7 @@
     # Define the status messages
     status_messages = {
         'CMD_UNKNOWN'      : "500 '%s': command not understood.",
+        'INTERNAL_ERROR'   : "500 Internal error: %s",
         'LOGIN_REQUIRED'   : '530 Please log in with USER and PASS',
         }
 
@@ -84,8 +86,7 @@
             try:
                 getattr(self, method)(command.args)
             except:
-                import traceback
-                traceback.print_exc()
+                self.exception()
         else:
             self.reply(self.unknown_reply, cmd.upper())
         return None
@@ -104,3 +105,13 @@
             self.flush(0)
 
         # XXX: Some logging should go on here.
+
+
+    def exception(self):
+        t, v = sys.exc_info()[:2]
+        try:
+            info = '%s: %s' % (getattr(t, '__name__', t), v)
+        except:
+            info = str(t)
+        self.reply('INTERNAL_ERROR', info)
+        self.handle_error()


=== Zope3/lib/python/Zope/Server/LineReceiver/LineTask.py 1.1.2.2 => 1.1.2.3 ===
                 if self.channel.adj.log_socket_errors:
                     raise
+            except:
+                self.channel.exception()
         finally:
             self.channel.end_task(self.close_on_finish)