1
Fork 0

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:
Michael Zapata 2016-12-05 03:21:08 +01:00
parent 8d66181b5e
commit 430d39da9d
No known key found for this signature in database
GPG key ID: 4507F0A29F6026DA
2 changed files with 29 additions and 13 deletions

View file

@ -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
}