use more accurate exceptions
authorThomas Nagy <tnagy1024@gmail.com>
Sat, 3 Sep 2011 22:17:31 +0000 (22:17 +0000)
committerThomas Nagy <tnagy1024@gmail.com>
Sat, 3 Sep 2011 22:17:31 +0000 (22:17 +0000)
git-svn-id: https://waf.googlecode.com/svn/trunk@11569 f0382ac9-c320-0410-b3f0-b508d59f5a85

waflib/extras/netcache_client.py

index 037fc55d9536a5000b8719ec983a0f420a6aa8dc..8aaebfd735dbbea251dcb7f5e206d455f55d7f5a 100644 (file)
@@ -119,6 +119,9 @@ def check_cache(conn, ssig):
        if not ssig in all_sigs_in_cache[1]:
                raise ValueError('no file %s in cache' % ssig)
 
+class MissingFile(Exception):
+       pass
+
 def recv_file(conn, ssig, count, p):
        check_cache(conn, ssig)
 
@@ -129,7 +132,7 @@ def recv_file(conn, ssig, count, p):
        size = int(data.split(',')[0])
 
        if size == -1:
-               raise ValueError('no file %s - %s in cache' % (ssig, count))
+               raise MissingFile('no file %s - %s in cache' % (ssig, count))
 
        # get the file, writing immediately
        # TODO a tmp file would be better
@@ -183,12 +186,16 @@ def can_retrieve_cache(self):
        conn = None
        err = False
        try:
-               conn = get_connection()
                try:
+                       conn = get_connection()
                        for node in self.outputs:
                                p = node.abspath()
                                recv_file(conn, ssig, cnt, p)
                                cnt += 1
+               except MissingFile:
+                       Logs.debug('netcache: file is not in the cache %r' % e)
+                       err = True
+
                except Exception, e:
                        Logs.debug('netcache: could not get the files %r' % e)
                        err = True