upload_symbols: Refactor error handling for duplicates

The retry logic does not handle custom exceptions therefore duplicate
file checks, which were thrown as handled exceptions, were falling
through and being thrown as HTTP exceptions.

Removed the custom exception and handled the duplicate check by setting
status if found.

BUG=chromium:956599
TEST='cros_sdk -- /mnt/host/source/chromite/run_tests'

Change-Id: I2343941db20759fe9277efbe04fc63221b32d385
Reviewed-on: https://chromium-review.googlesource.com/1593468
Commit-Ready: Mike Nichols <mikenichols@chromium.org>
Tested-by: Mike Nichols <mikenichols@chromium.org>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
(cherry picked from commit b03b2c67e067d7932d8b4aa97e3380d7daeee119)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1597132
Reviewed-by: David Burger <dburger@chromium.org>
Commit-Queue: Mike Nichols <mikenichols@chromium.org>
diff --git a/scripts/upload_symbols.py b/scripts/upload_symbols.py
index 7d2f699..c818c5c 100644
--- a/scripts/upload_symbols.py
+++ b/scripts/upload_symbols.py
@@ -120,9 +120,6 @@
 UPLOAD_STATS = 'UPLOAD'
 
 
-class DuplicateFile(Exception):
-  """Thrown when a symbol file already exists on the server."""
-
 def BatchGenerator(iterator, batch_size):
   """Given an iterator, break into lists of size batch_size.
 
@@ -388,8 +385,9 @@
   '''
   timeout = GetUploadTimeout(symbol)
   if UploadExists(symbol, upload_url, timeout, api_key):
-    logging.info('%s symbol file already uploaded, skipping', symbol.header.id)
-    raise DuplicateFile
+    logging.info('%s/%s symbol file already uploaded, skipping',
+                 symbol.header.id, symbol.header.name)
+    symbol.status = SymbolFile.DUPLICATE
   else:
     upload = ExecRequest('post',
                          '%s/uploads:create' % upload_url, timeout, api_key)
@@ -449,10 +447,10 @@
               upload_url, s, api_key,
               sleep=INITIAL_RETRY_DELAY,
               log_all_retries=True)
-        logging.info('upload of %10i bytes took %s', s.FileSize(), timer.delta)
-        s.status = SymbolFile.UPLOADED
-      except DuplicateFile:
-        s.status = SymbolFile.DUPLICATE
+        if s.status != SymbolFile.DUPLICATE:
+          logging.info('upload of %10i bytes took %s', s.FileSize(),
+                       timer.delta)
+          s.status = SymbolFile.UPLOADED
       except (requests.exceptions.HTTPError,
               requests.exceptions.Timeout,
               requests.exceptions.RequestException) as e: