Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#6615) Fixed --ls error messages by refactoring get_metadata_section #12758

Merged
merged 1 commit into from
Mar 9, 2014
Merged

(#6615) Fixed --ls error messages by refactoring get_metadata_section #12758

merged 1 commit into from
Mar 9, 2014

Conversation

robertg
Copy link

@robertg robertg commented Mar 7, 2014

Refactored get_metadata_section to return a Result<MetadataBlob,~str> instead of a Option. This provides more clarity to the user through the debug output when using --ls.

This is kind of a continuation of my original closed pull request 2 months ago (#11544), but I think the time-span constitutes a new pull request.

@@ -404,19 +404,24 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
Some(ar) => ar,
None => {
debug!("llvm didn't like `{}`", filename.display());
return None;
return Err(format!("llvm didn't like '{}'", filename.display()));
Copy link
Member

Choose a reason for hiding this comment

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

as a user-facing error message, "llvm didn't like" is probably not the best wording, perhaps "failed to read rlib metadata: ..."

@robertg
Copy link
Author

robertg commented Mar 8, 2014

Alright Alex, I updated those error messages and made them lower case.

@flaper87
Copy link
Contributor

flaper87 commented Mar 8, 2014

Could you please reference #6615 and add Closes in the commit message? Also, could you please squash those commits into 1?

@@ -395,7 +395,7 @@ fn get_metadata_section(os: Os, filename: &Path) -> Option<MetadataBlob> {
return ret;
}

fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~str> {
if filename.filename_str().unwrap().ends_with(".rlib") {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also verify if the file exists before this if:

if !filename.exists() {
    return Err(format!("No such file {}", filename.display()));
}

@robertg
Copy link
Author

robertg commented Mar 9, 2014

Alright FlaPer87, I squashed the commits and added your file existence check to get_metadata_section_imp.

@alexcrichton
Copy link
Member

The error messages returned from this method are still a bit inconsistent. I've seen these formats:

message {}
message '{}'
message: {}
message: '{}'

This should be consistent in the formatting of the error messages:

message: `{}`

Also, remember that all error messages start with lower case letters, there's still one that starts with a capital letter.

@robertg
Copy link
Author

robertg commented Mar 9, 2014

Alright, I fixed the error messages, and the newest one requested by flapper87 which had the capital case.

bors added a commit that referenced this pull request Mar 9, 2014
Refactored get_metadata_section to return a Result<MetadataBlob,~str> instead of a Option<MetadataBlob>. This provides more clarity to the user through the debug output when using --ls.

This is kind of a continuation of my original closed pull request 2 months ago (#11544), but I think the time-span constitutes a new pull request.
@bors bors closed this Mar 9, 2014
@bors bors merged commit 3bf724e into rust-lang:master Mar 9, 2014
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.

4 participants