python/ovs/socket_util: don't use Exception, but ValueError
authorIsaku Yamahata <yamahata@valinux.co.jp>
Mon, 15 Oct 2012 21:57:27 +0000 (06:57 +0900)
committerBen Pfaff <blp@nicira.com>
Tue, 16 Oct 2012 17:19:49 +0000 (10:19 -0700)
67656b9ff297f305b3bfcca2868e8e870e108283
used Exception, but it should be more specific error.
Use ValueError instread of Exception.

Suggested-by: Reid Price <reid@nicira.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
python/ovs/socket_util.py

index 845511e3b209a556ca353b27b43fb308e730ba6d..dd45fe4b92520561442d990ffdbe55f3ec2d5623 100644 (file)
@@ -88,13 +88,13 @@ def inet_parse_active(target, default_port):
     address = target.split(":")
     host_name = address[0]
     if not host_name:
-        raise Exception("%s: bad peer name format" % target)
+        raise ValueError("%s: bad peer name format" % target)
     if len(address) >= 2:
         port = int(address[1])
     elif default_port:
         port = default_port
     else:
-        raise Exception("%s: port number must be specified" % target)
+        raise ValueError("%s: port number must be specified" % target)
     return (host_name, port)
 
 
@@ -187,6 +187,6 @@ def set_nonblocking(sock):
 
 def set_dscp(sock, dscp):
     if dscp > 63:
-        raise Exception("Invalid dscp %d" % dscp)
+        raise ValueError("Invalid dscp %d" % dscp)
     val = dscp << 2
     sock.setsockopt(socket.IPPROTO_IP, socket.IP_TOS, val)