Skip to content

Commit

Permalink
Merge pull request #515 from cuviper/historical-rust
Browse files Browse the repository at this point in the history
Chain ErrorKind::HttpStatus(404) to Download404
  • Loading branch information
brson committed Jun 7, 2016
2 parents 3bae543 + b2b9ac8 commit 8d1633f
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/rustup-utils/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,24 @@ pub fn download_file(url: &Url,
notify_handler(Notification::DownloadingFile(url, path));
match raw::download_file(url, path, hasher, notify_handler) {
Ok(_) => Ok(()),
Err(Error(ErrorKind::HttpError(e), d)) => {
if e.is_file_couldnt_read_file() {
return Err(Error(ErrorKind::HttpError(e), d)).chain_err(|| {
ErrorKind::Download404 {
url: url.clone(),
path: path.to_path_buf(),
}
})
}
Err(Error(ErrorKind::HttpError(e), d)).chain_err(|| {
Err(e) => {
let is404 = match e.kind() {
&ErrorKind::HttpStatus(404) => true,
&ErrorKind::HttpError(ref e) => e.is_file_couldnt_read_file(),
_ => false
};
Err(e).chain_err(|| if is404 {
ErrorKind::Download404 {
url: url.clone(),
path: path.to_path_buf(),
}
} else {
ErrorKind::DownloadingFile {
url: url.clone(),
path: path.to_path_buf(),
}
})
}
Err(e) => {
Err(e).chain_err(|| ErrorKind::DownloadingFile {
url: url.clone(),
path: path.to_path_buf(),
})
}
}
}

Expand Down

0 comments on commit 8d1633f

Please sign in to comment.