From 5f85394f62330d5536e57701b17703b6fc404c6c Mon Sep 17 00:00:00 2001 From: steven-omaha <35634100+steven-omaha@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:51:55 +0100 Subject: [PATCH] clean up main error handling --- crates/main/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/main/main.rs b/crates/main/main.rs index 5b4f357..aa3e084 100644 --- a/crates/main/main.rs +++ b/crates/main/main.rs @@ -31,10 +31,11 @@ fn handle_final_result(result: Result<()>) -> ExitCode { match result { Ok(_) => ExitCode::SUCCESS, Err(ref e) => { - if e.root_cause().to_string() == pacdef_core::Error::NoPackagesFound.to_string() { - ExitCode::FAILURE - } else { - result.report() + let root_e = e.root_cause().downcast_ref(); + match root_e { + Some(pacdef_core::Error::NoPackagesFound) => ExitCode::FAILURE, + Some(_) => ExitCode::FAILURE, + None => result.report(), } } }