mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-11 02:44:15 +00:00
define error handlers
This commit is contained in:
parent
c1bc99125e
commit
52e7e0359f
@ -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…
x
Reference in New Issue
Block a user