improve yt-dl error output
This commit is contained in:
parent
8d386dadbb
commit
77af8b5cad
1 changed files with 15 additions and 2 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue