Skip to content

Added error for downloading bogus versions#428

Merged
brson merged 1 commit intorust-lang:masterfrom
cramertj:master
May 10, 2016
Merged

Added error for downloading bogus versions#428
brson merged 1 commit intorust-lang:masterfrom
cramertj:master

Conversation

@cramertj
Copy link
Copy Markdown
Member

Fixes #390

I'm not sure if this is exactly what you had in mind-- I didn't see quite how to compose it with chain_err without catching all of the errors returned from the call to update_v1, but I got it working nonetheless.

Ok(Some(hash)) => Ok(Some(hash)),
Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404 { .. }), e)) => {
Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404BadVers { vers: toolchain_str }), e))
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get rid of some of this boilerplate how about something like

e @ Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404 { .. }), _)) = {
   e.chain_err(|| format!("could not download nonexistent rust version `{}`", toolchain_str)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's it! I was neglecting the @ syntax.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the change.

@brson brson merged commit a9fa226 into rust-lang:master May 10, 2016
@brson
Copy link
Copy Markdown
Contributor

brson commented May 10, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants