devserver: fix exception related discrepancies

* DeltaPayloadsArtifact._Setup() neglected to (re-)raise and exception
  when an error occurred. This contradicts the docstring and a likely
  cause for inconsistencies surrounding missing artifact files.

* BuildArtifact.Process() caught and re-raised any exception, although
  it's only supposed to be raising BuildArtifactError. We now convert
  any unknown exception into the latter (albeit losing the stack trace).
  This necessitates that we adjust our handling of exception at call
  sites for build_artifact, too.

BUG=chromium:277839
TEST=Unit tests.

Change-Id: I30a87e9722460fdbfab54c3ff60e1d7a8013b3cb
Reviewed-on: https://chromium-review.googlesource.com/176932
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
diff --git a/build_artifact.py b/build_artifact.py
index bb8ec46..38d8d59 100755
--- a/build_artifact.py
+++ b/build_artifact.py
@@ -172,7 +172,7 @@
     with open(os.path.join(self.install_dir, self.marker_name), 'w') as f:
       f.write('\n'.join(self.installed_files))
 
-  def WaitForArtifactToExist(self, timeout, update_name=True):
+  def _WaitForArtifactToExist(self, timeout, update_name=True):
     """Waits for artifact to exist and sets self.name to appropriate name.
 
     Args:
@@ -274,14 +274,19 @@
           # If the artifact should already have been uploaded, don't waste
           # cycles waiting around for it to exist.
           timeout = 1 if no_wait else 10
-          self.WaitForArtifactToExist(timeout)
+          self._WaitForArtifactToExist(timeout)
           self._Download()
           self._Setup()
           self._MarkArtifactStaged()
         except Exception as e:
           # Save the exception to a file for downloader.IsStaged to retrieve.
           self._SaveException(e)
-          raise
+
+          # Convert an unknown exception into an ArtifactDownloadError.
+          if type(e) is ArtifactDownloadError:
+            raise
+          else:
+            raise ArtifactDownloadError('An error occurred: %s' % e)
       else:
         self._Log('%s is already staged.', self)
 
@@ -371,6 +376,7 @@
         self.installed_files.append(stateful_update_symlink)
       except ArtifactDownloadError as e:
         self._Log('Could not process %s: %s', artifact, e)
+        raise
 
 
 class BundledBuildArtifact(BuildArtifact):