improve yt-dl error output

This commit is contained in:
hodasemi 2018-11-25 19:30:53 +01:00
parent 8d386dadbb
commit 77af8b5cad

View file

@ -52,11 +52,24 @@ pub fn youtube_dl(uri: &str) -> Result<Vec<Song>, String> {
.output()
{
Ok(out) => out,
Err(_) => return Err("youtube-dl error".to_string()),
Err(why) => return Err(format!("youtube-dl error {:?}", why)),
};
if !out.status.success() {
return Err("shell error".to_string());
let stdout = match String::from_utf8(out.stdout) {
Ok(string) => string,
Err(_) => String::new(),
};
let stderr = match String::from_utf8(out.stderr) {
Ok(string) => string,
Err(_) => String::new(),
};
return Err(format!(
"Shell error\nstdout: {}\nstderr: {}",
stdout, stderr
));
}
let files = check_result!(convert_output(&out));