src/modules/misc.py
changeset 670 2785b97791ed
parent 660 ea2809ad4582
child 696 6bbfd2dece6f
--- a/src/modules/misc.py	Mon Nov 03 14:06:05 2008 -0800
+++ b/src/modules/misc.py	Mon Nov 03 14:12:03 2008 -0800
@@ -459,6 +459,29 @@
                         s += "\n"
                 return s
 
+class TransferIOException(TransportException):
+        """Raised for retryable IO errors on underlying transport.
+        Protocol errors are TransferContentExceptions, timeouts
+        are TransferTimedOutExceptions."""
+        def __init__(self, url, reason=None):
+                TransportException.__init__(self)
+                self.url = url
+                self.reason = reason
+
+        def __str__(self):
+                s = "IO Error while communicating with '%s'" % self.url
+                if self.reason:
+                        s += ": %s" % self.reason
+                s += "."
+                return s
+
+        def __cmp__(self, other):
+                if not isinstance(other, TransferIOException):
+                        return -1        
+                r = cmp(self.url, other.url)
+                if r != 0:
+                        return r
+                return cmp(self.reason, other.reason)
 
 class TransferTimedOutException(TransportException):
         """Raised when the transfer times out, or is terminated with a