From a027922b0e051b4eecc50ebbf96e511cae29664d Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sat, 2 Nov 2024 11:07:25 +0100 Subject: [PATCH] impl Error for subsonic error and one other thing --- src/subsonic.rs | 10 ++++++++++ src/ui/setup.rs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/subsonic.rs b/src/subsonic.rs index d7b09b1..92fb7de 100644 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -30,6 +30,16 @@ impl fmt::Display for Error { } } +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Self::UrlParseError(err) => err.source(), + Self::ReqwestError(err) => err.source(), + _ => None, + } + } +} + impl From for Error { fn from(err: reqwest::Error) -> Self { // don't print secret salt/token combo diff --git a/src/ui/setup.rs b/src/ui/setup.rs index 1b078f1..71662a7 100644 --- a/src/ui/setup.rs +++ b/src/ui/setup.rs @@ -88,7 +88,7 @@ mod imp { match api.ping().await { Ok(()) => { self.obj().set_status("Connected"); - self.save_async().await; + self.save().await; // please REMOVEME once we've killed vala fn get_random_salt(length: usize) -> String { @@ -126,7 +126,7 @@ mod imp { self.obj().set_authn_can_edit(true); } - async fn save_async(&self) { + async fn save(&self) { self.obj().set_authn_can_edit(false); // TODO remove unwraps etc etc