immutable: download.py: Raise the appropriate type of exception to indicate the cause...
authorZooko O'Whielacronx <zooko@zooko.com>
Fri, 2 Jan 2009 19:58:58 +0000 (12:58 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Fri, 2 Jan 2009 19:58:58 +0000 (12:58 -0700)
src/allmydata/immutable/download.py

index ce40ba929e8dbee04bbb2f9804da5ddd3cae7a39..fda9ef2a696d1e7d138688a9ddcb40e780a2724a 100644 (file)
@@ -9,6 +9,7 @@ from foolscap.eventual import eventually
 
 from allmydata.util import base32, mathutil, hashutil, log
 from allmydata.util.assertutil import _assert, precondition
+from allmydata.util.rrefutil import ServerFailure
 from allmydata import codec, hashtree, uri
 from allmydata.interfaces import IDownloadTarget, IDownloader, IFileURI, IVerifierURI, \
      IDownloadStatus, IDownloadResults, IValidatedThingProxy, NotEnoughSharesError
@@ -162,7 +163,7 @@ class ValidatedCrypttextHashTreeProxy:
         except (hashtree.BadHashError, hashtree.NotEnoughHashesError), le:
             if self._fetch_failures is not None:
                 self._fetch_failures["crypttext_hash_tree"] += 1
-            raise
+            raise BadOrMissingHash(le)
         return self
 
     def start(self):
@@ -494,8 +495,12 @@ class BlockDownloader(log.PrefixingLogMixin):
         self.parent.hold_block(self.blocknum, data)
 
     def _got_block_error(self, f):
-        failtype = f.trap(DeadReferenceError, IntegrityCheckReject)
-        self.log("failure to get block", level=log.UNUSUAL, umid="5Z4uHQ")
+        failtype = f.trap(ServerFailure, IntegrityCheckReject, layout.LayoutInvalid)
+        if f.check(ServerFailure):
+            level = log.UNUSUAL
+        else:
+            level = log.WEIRD
+        self.log("failure to get block", level=level, umid="5Z4uHQ")
         if self.results:
             peerid = self.vbucket.bucket.get_peerid()
             self.results.server_problems[peerid] = str(f)