From 3bbe4672d7ad9af5dce1c71fb56c3bed2a42b9ee Mon Sep 17 00:00:00 2001 From: dachshund Date: Wed, 4 Sep 2013 17:29:06 -0400 Subject: [PATCH] Replace generic exception with a specific one. --- tuf/download.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tuf/download.py b/tuf/download.py index ed80c370..0321a72d 100755 --- a/tuf/download.py +++ b/tuf/download.py @@ -336,7 +336,7 @@ def _open_connection(url): URL string (e.g., 'http://...' or 'ftp://...' or 'file://...') - tuf.DownloadError + None. Opens a connection to a remote server. @@ -590,8 +590,8 @@ def _check_downloaded_length(total_downloaded, required_length, None. - tuf.DownloadError, if STRICT_REQUIRED_LENGTH is True and total_downloaded - is not equal required_length. + tuf.DownloadLengthMismatchError, if STRICT_REQUIRED_LENGTH is True and + total_downloaded is not equal required_length. None. @@ -612,7 +612,7 @@ def _check_downloaded_length(total_downloaded, required_length, if STRICT_REQUIRED_LENGTH: # This must be due to a programming error, and must never happen! logger.error(message) - raise tuf.DownloadError(message) + raise tuf.DownloadLengthMismatchError(message) else: # We specifically disabled strict checking of required length, but we # will log a warning anyway. This is useful when we wish to download the @@ -660,12 +660,11 @@ def download_url_to_tempfileobj(url, required_length, required_hashes=None, 'url'. - tuf.DownloadError, if there was an error while downloading the file. + tuf.DownloadLengthMismatchError, if there was a mismatch of observed vs + expected lengths while downloading the file. tuf.FormatError, if any of the arguments are improperly formatted. - tuf.BadHashError, if the hashes don't match. - Any other unforeseen runtime exception.