add error GroupFileNotFound
This commit is contained in:
+6
-5
@@ -28,15 +28,16 @@ fn main() -> ExitCode {
|
|||||||
|
|
||||||
/// Skip printing the error chain when searching packages yields no results,
|
/// Skip printing the error chain when searching packages yields no results,
|
||||||
/// otherwise report error chain.
|
/// otherwise report error chain.
|
||||||
|
#[allow(clippy::option_if_let_else)]
|
||||||
fn handle_final_result(result: Result<()>) -> ExitCode {
|
fn handle_final_result(result: Result<()>) -> ExitCode {
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => ExitCode::SUCCESS,
|
Ok(_) => ExitCode::SUCCESS,
|
||||||
Err(ref e) => {
|
Err(ref e) => {
|
||||||
let root_e = e.root_cause().downcast_ref();
|
if let Some(root_error) = e.root_cause().downcast_ref::<pacdef_core::Error>() {
|
||||||
match root_e {
|
eprintln!("{root_error}");
|
||||||
Some(pacdef_core::Error::NoPackagesFound) => ExitCode::FAILURE,
|
ExitCode::FAILURE
|
||||||
Some(_) => result.context("unknown pacdef error type").report(),
|
} else {
|
||||||
None => result.report(),
|
result.report()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ fn get_group_file_paths_matching_args<'a>(
|
|||||||
Some(group) => {
|
Some(group) => {
|
||||||
result.push(group.path.as_path());
|
result.push(group.path.as_path());
|
||||||
}
|
}
|
||||||
None => bail!("group file {} not found", file),
|
None => bail!(crate::errors::Error::GroupFileNotFound(file.clone())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ pub enum Error {
|
|||||||
NoPackagesFound,
|
NoPackagesFound,
|
||||||
/// Config file not found.
|
/// Config file not found.
|
||||||
ConfigFileNotFound,
|
ConfigFileNotFound,
|
||||||
|
/// Group file not found.
|
||||||
|
GroupFileNotFound(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
@@ -16,6 +18,7 @@ impl Display for Error {
|
|||||||
match self {
|
match self {
|
||||||
Self::NoPackagesFound => f.write_str("no packages matching query"),
|
Self::NoPackagesFound => f.write_str("no packages matching query"),
|
||||||
Self::ConfigFileNotFound => f.write_str("config file not found"),
|
Self::ConfigFileNotFound => f.write_str("config file not found"),
|
||||||
|
Self::GroupFileNotFound(name) => f.write_str(&format!("group file '{name}' not found")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user