improve error logging
This commit is contained in:
parent
dcb9c50d29
commit
661f0f04e3
|
@ -141,10 +141,18 @@ pub trait Module {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: error handling
|
|
||||||
let request: Self::Request = serde_json::from_value(value).expect("good value");
|
match serde_json::from_value::<Self::Request>(value.clone()) {
|
||||||
let response = Self::handle_request(request)?;
|
Ok(request) => {
|
||||||
println!("{}", serde_json::to_string(&response).unwrap());
|
let response = Self::handle_request(request)?;
|
||||||
|
println!("{}", serde_json::to_string(&response).unwrap());
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Failed to parse request: {e}");
|
||||||
|
eprintln!("Offending JSON value: {value:?}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,12 +174,18 @@ pub fn do_cli_thing() {
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| format!("icepick-{module_name}"));
|
.unwrap_or_else(|| format!("icepick-{module_name}"));
|
||||||
let (command, args) = get_command(&bin);
|
let (command, args) = get_command(&bin);
|
||||||
let mut child = Command::new(command)
|
let mut child = match Command::new(&command)
|
||||||
.args(args)
|
.args(&args)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
{
|
||||||
|
Ok(child) => child,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Failed to spawn command `{}`: {}", command, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
let mut input = child.stdin.take().unwrap();
|
let mut input = child.stdin.take().unwrap();
|
||||||
input
|
input
|
||||||
.write_all("{\"operation\": \"help\"}\n".as_bytes())
|
.write_all("{\"operation\": \"help\"}\n".as_bytes())
|
||||||
|
|
Loading…
Reference in New Issue