diff --git a/data/ui/response_panel.blp b/data/ui/response_panel.blp index c4a753c..11fcc5a 100644 --- a/data/ui/response_panel.blp +++ b/data/ui/response_panel.blp @@ -36,11 +36,13 @@ template $CarteroResponsePanel: Adw.Bin { child: Adw.StatusPage error_page { icon-name: "network-error-symbolic"; - title: _("Request error"); + title: _("Cannot perform request"); child: Gtk.Label error_extra { - label: "PRUEBA"; + label: ""; selectable: true; + opacity: 0.75; + wrap: true; }; }; } diff --git a/src/client/local.rs b/src/client/local.rs index d2ab4aa..bb0d5d1 100644 --- a/src/client/local.rs +++ b/src/client/local.rs @@ -213,6 +213,17 @@ pub enum RequestError { IOError(#[from] std::io::Error), } +impl RequestError { + pub fn inner_error(&self) -> String { + match self { + Self::NetworkError(isahc) => isahc.to_string(), + Self::HttpError(isahc) => isahc.to_string(), + Self::IOError(io) => io.to_string(), + _ => self.to_string(), + } + } +} + #[cfg(test)] mod tests { use crate::entities::KeyValueTable; diff --git a/src/widgets/response_panel.rs b/src/widgets/response_panel.rs index 1e64f6b..9d89e30 100644 --- a/src/widgets/response_panel.rs +++ b/src/widgets/response_panel.rs @@ -157,9 +157,23 @@ mod imp { pub(super) fn show_error(&self, error: CarteroError) { // TODO: Internationalize - let message = error.to_string(); + println!("{error:?}"); + let message = match &error { + CarteroError::Request(inner) => inner.to_string(), + _ => error.to_string(), + }; + + match &error { + CarteroError::Request(inner) => { + self.error_extra.set_visible(true); + self.error_extra.set_label(&inner.inner_error()); + } + _ => { + self.error_extra.set_visible(false); + } + } + self.error_page.set_description(Some(&message)); - self.error_extra.set_visible(false); self.stack.set_visible_child_name("error"); } }