made exceptions a litte more generic, passing msg to superclass for networexception
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Sun, 6 Jan 2008 20:22:57 +0000 (20:22 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Sun, 6 Jan 2008 20:22:57 +0000 (20:22 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1200 9efc2488-bf62-4759-914b-345cdb29e865

src/python/osrf/ex.py

index af7177e..f62aca8 100644 (file)
 class OSRFException(Exception):
     """Root class for exceptions."""
     def __init__(self, info=None):
-        self.info = info;
+        self.msg = '%s: %s' % (self.__class__.__name__, info)
     def __str__(self):
-        return self.info
+        return self.msg
 
 
 class NetworkException(OSRFException):
-    def __str__(self):
-        msg = "\nUnable to communicate with the OpenSRF network"
-        if self.info:
-            msg = msg + '\n' + unicode(self.info)
-        return msg
+    def __init__(self):
+        OSRFException.__init__('Error communicating with the OpenSRF network')
 
 class OSRFProtocolException(OSRFException):
     """Raised when something happens during opensrf network stack processing."""