combine ExecError with LaunchError and use Session::try_get() instead of matching
This commit is contained in:
@ -7,7 +7,7 @@ use crate::errors::*;
|
||||
use crate::state::AppState;
|
||||
|
||||
|
||||
pub async fn launch(use_base: bool) -> Result<(), LaunchError> {
|
||||
pub async fn launch(use_base: bool) -> Result<(), ExecError> {
|
||||
let state = APP.get().unwrap().state::<AppState>();
|
||||
// do all this in a block so we don't hold the lock any longer than necessary
|
||||
let mut cmd = {
|
||||
@ -35,14 +35,9 @@ pub async fn launch(use_base: bool) -> Result<(), LaunchError> {
|
||||
|
||||
match cmd.spawn() {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => {
|
||||
use std::io::ErrorKind::*;
|
||||
if let NotFound = e.kind() {
|
||||
Err(LaunchError::ExeNotFound(cmd.get_program().to_owned()))
|
||||
}
|
||||
else {
|
||||
Err(LaunchError::from(e))
|
||||
}
|
||||
}
|
||||
Err(e) if std::io::ErrorKind::NotFound == e.kind() => {
|
||||
Err(ExecError::NotFound(cmd.get_program().to_owned()))
|
||||
},
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user