refactor(link): add Ok and make IoError more understandable

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-10-17 07:46:29 +02:00
parent f17e2a5986
commit 4a0f855b67
Signed by: cafkafk
GPG key ID: 26C542FD97F965CE

View file

@ -598,6 +598,10 @@ impl Config {
let mut sp = let mut sp =
Spinner::new(Spinners::Dots10, format!("{}: {}", link.name, op)); Spinner::new(Spinners::Dots10, format!("{}: {}", link.name, op));
match f(link) { match f(link) {
Ok(_) => sp.stop_and_persist(
success_str(),
format!("{}: {}", link.name, op),
),
Err(e @ LinkError::AlreadyLinked(_, _)) => { Err(e @ LinkError::AlreadyLinked(_, _)) => {
sp.stop_and_persist(success_str(), format!("{e}")) sp.stop_and_persist(success_str(), format!("{e}"))
} }
@ -613,9 +617,10 @@ impl Config {
Err(e @ LinkError::FailedCreatingLink(_, _)) => { Err(e @ LinkError::FailedCreatingLink(_, _)) => {
sp.stop_and_persist(failure_str(), format!("{e}")) sp.stop_and_persist(failure_str(), format!("{e}"))
} }
Err(e @ LinkError::IoError(_)) => { Err(e @ LinkError::IoError(_)) => sp.stop_and_persist(
sp.stop_and_persist(failure_str(), format!("{e}")) failure_str(),
} format!("{}: {op}, {e}", link.name),
),
Err(e) => sp.stop_and_persist(failure_str(), format!("{e}")), Err(e) => sp.stop_and_persist(failure_str(), format!("{e}")),
_ => sp.stop_and_persist( _ => sp.stop_and_persist(
failure_str(), failure_str(),