-
Notifications
You must be signed in to change notification settings - Fork 13.3k
feat(rustdoc): harmonise error messages #38179
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, | |
let mut out = match File::create(&output) { | ||
Err(e) => { | ||
let _ = writeln!(&mut io::stderr(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
||
"error opening `{}` for writing: {}", | ||
"rustdoc: {}: {}", | ||
output.display(), e); | ||
return 4; | ||
} | ||
|
@@ -80,8 +80,10 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, | |
|
||
let (metadata, text) = extract_leading_metadata(&input_str); | ||
if metadata.is_empty() { | ||
let _ = writeln!(&mut io::stderr(), | ||
"invalid markdown file: expecting initial line with `% ...TITLE...`"); | ||
let _ = writeln!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
||
&mut io::stderr(), | ||
"rustdoc: invalid markdown file: expecting initial line with `% ...TITLE...`" | ||
); | ||
return 5; | ||
} | ||
let title = metadata[0]; | ||
|
@@ -132,7 +134,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, | |
match err { | ||
Err(e) => { | ||
let _ = writeln!(&mut io::stderr(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
||
"error writing to `{}`: {}", | ||
"rustdoc: cannot write to `{}`: {}", | ||
output.display(), e); | ||
6 | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using
print_error
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the prompting for
--help
should only be used for error in the invocation syntax, such as missing operands or missing arguments.The same goes for every other non-covered call.