feat(rustdoc): harmonise error messages
Based on unix tools wording, it follows a standard format: `program_name: context: error message` on stderr, prompting the user to use the `--help` option in case of misuse.
This commit is contained in:
parent
8d66181b5e
commit
430d39da9d
2 changed files with 29 additions and 13 deletions
|
@ -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(),
|
||||
"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!(
|
||||
&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(),
|
||||
"error writing to `{}`: {}",
|
||||
"rustdoc: cannot write to `{}`: {}",
|
||||
output.display(), e);
|
||||
6
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue