Browse Source

define error handlers

master
yggverse 1 month ago
parent
commit
52e7e0359f
  1. 121
      src/app/browser/window/tab/item/page.rs

121
src/app/browser/window/tab/item/page.rs

@ -351,10 +351,20 @@ impl Page {
todo!() todo!()
}, },
_ => { _ => {
meta.borrow_mut().status = Some(Status::Failure); // Define common data
meta.borrow_mut().title = Some(gformat!("Oops")); let status = Status::Failure;
meta.borrow_mut().description = Some(gformat!("Content {mime} not supported")); let title = gformat!("Oops");
let description = gformat!("Content {mime} not supported");
// Update widget
content.set_status_failure(title.as_str(), description.as_str());
// Update meta
meta.borrow_mut().status = Some(status);
meta.borrow_mut().title = Some(title);
meta.borrow_mut().description = Some(description);
// Update window
action_update.activate(Some(&id)); action_update.activate(Some(&id));
}, },
} }
@ -384,69 +394,115 @@ impl Page {
}, },
// @TODO // @TODO
_ => { _ => {
// Update // Define common data
meta.borrow_mut().status = Some(Status::Failure); let status = Status::Failure;
meta.borrow_mut().title = Some(gformat!("Oops")); let title = gformat!("Oops");
meta.borrow_mut().description = Some(gformat!("Status {code} not supported")); let description = gformat!("Status {code} not supported");
// Update widget
content.set_status_failure(title.as_str(), description.as_str());
// Update meta
meta.borrow_mut().status = Some(status);
meta.borrow_mut().title = Some(title);
meta.borrow_mut().description = Some(description);
// Update window
action_update.activate(Some(&id)); action_update.activate(Some(&id));
}, },
} }
None => todo!(), None => todo!(),
}; };
} }
Err(e) => { Err(error) => {
meta.borrow_mut().status = Some(Status::Failure); // Define common data
meta.borrow_mut().title = Some(gformat!("Oops")); let status = Status::Failure;
meta.borrow_mut().description = Some(gformat!("Failed to read buffer data: {e}")); let title = gformat!("Oops");
let description = gformat!("Failed to read buffer data: {:?}", error);
// Update widget
content.set_status_failure(title.as_str(), description.as_str());
// Update meta
meta.borrow_mut().status = Some(status);
meta.borrow_mut().title = Some(title);
meta.borrow_mut().description = Some(description);
// Update window
action_update.activate(Some(&id)); action_update.activate(Some(&id));
} }
} }
// Close connection // Close connection
if let Err(e) = connection.close(Some(&cancellable)) { if let Err(error) = connection.close(Some(&cancellable)) {
todo!("Error closing connection: {:?}", e); todo!("Error closing connection: {}", error.message());
} }
} }
Err(e) => { Err(error) => {
// Update // Define common data
meta.borrow_mut().status = Some(Status::Failure); let status = Status::Failure;
meta.borrow_mut().title = Some(gformat!("Oops")); let title = gformat!("Oops");
meta.borrow_mut().description = Some(gformat!("Failed to read response: {:?}", e)); let description = gformat!("Failed to read response: {}", error.1.message());
// Update widget
content.set_status_failure(title.as_str(), description.as_str());
// Update meta
meta.borrow_mut().status = Some(status);
meta.borrow_mut().title = Some(title);
meta.borrow_mut().description = Some(description);
// Update window
action_update.activate(Some(&id)); action_update.activate(Some(&id));
// Close connection // Close connection
if let Err(e) = connection.close(Some(&cancellable)) { if let Err(error) = connection.close(Some(&cancellable)) {
todo!("Error closing response connection: {:?}", e); todo!("Error closing response connection: {}", error.message());
} }
} }
}, },
); );
} }
Err(e) => { Err(error) => {
// Update // Define common data
meta.borrow_mut().status = Some(Status::Failure); let status = Status::Failure;
meta.borrow_mut().title = Some(gformat!("Oops")); let title = gformat!("Oops");
meta.borrow_mut().description = Some(gformat!("Failed to read request: {:?}", e)); let description = gformat!("Failed to read request: {}", error.1.message());
// Update widget
content.set_status_failure(title.as_str(), description.as_str());
// Update meta
meta.borrow_mut().status = Some(status);
meta.borrow_mut().title = Some(title);
meta.borrow_mut().description = Some(description);
// Update window
action_update.activate(Some(&id)); action_update.activate(Some(&id));
// Close connection // Close connection
if let Err(e) = connection.close(Some(&cancellable)) { if let Err(error) = connection.close(Some(&cancellable)) {
todo!("Error closing request connection: {:?}", e); todo!("Error closing request connection: {}", error.message());
} }
} }
}, },
); );
} }
Err(e) => { Err(error) => {
// Update // Define common data
meta.borrow_mut().status = Some(Status::Failure); let status = Status::Failure;
meta.borrow_mut().title = Some(gformat!("Oops")); let title = gformat!("Oops");
meta.borrow_mut().description = Some(gformat!("Failed to connect: {:?}", e)); let description = gformat!("Failed to connect: {}", error.message());
// Update widget
content.set_status_failure(title.as_str(), description.as_str());
// Update meta
meta.borrow_mut().status = Some(status);
meta.borrow_mut().title = Some(title);
meta.borrow_mut().description = Some(description);
// Update window
action_update.activate(Some(&id)); action_update.activate(Some(&id));
} }
}, },
@ -456,6 +512,7 @@ impl Page {
"nex" => {} "nex" => {}
*/ */
scheme => { scheme => {
// Define common data
let status = Status::Failure; let status = Status::Failure;
let title = gformat!("Oops"); let title = gformat!("Oops");
let description = gformat!("Protocol `{scheme}` not supported"); let description = gformat!("Protocol `{scheme}` not supported");

Loading…
Cancel
Save