def getConnectError(e):
 if isinstance(e, Exception):
  args = e.args
 else:
  args = e
 try:
  (number, string) = args
 except ValueError:
  return ConnectError(string=e)
 if (hasattr(socket, 'gaierror') and isinstance(e, socket.gaierror)):
  klass = UnknownHostError
 else:
  klass = errnoMapping.get(number, ConnectError)
 return klass(number, string)

def getConnectError ( e ) : if isinstance ( e , Exception ) : args = e . args else : args = e try : ( number , string ) = args except ValueError : return ConnectError ( string = e ) if ( hasattr ( socket , 'gaierror' ) and isinstance ( e , socket . gaierror ) ) : klass = UnknownHostError else : klass = errnoMapping . get ( number , ConnectError ) return klass ( number , string )
given a socket exception .