mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
update error handle
This commit is contained in:
parent
00d130e107
commit
3179b6a33a
2 changed files with 24 additions and 28 deletions
31
src/app.rs
31
src/app.rs
|
|
@ -260,36 +260,17 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
pub fn run(&self) -> ExitCode {
|
pub fn run(&self) -> Result<ExitCode> {
|
||||||
// Begin database migration @TODO
|
// Begin database migration @TODO
|
||||||
{
|
{
|
||||||
// Init writable connection
|
let mut connection = self.profile.database.connection.write().unwrap();
|
||||||
let mut connection = match self.profile.database.connection.write() {
|
let transaction = connection.transaction()?;
|
||||||
Ok(connection) => connection,
|
migrate(&transaction)?;
|
||||||
Err(e) => todo!("{e}"),
|
transaction.commit()?;
|
||||||
};
|
|
||||||
|
|
||||||
// Init new transaction
|
|
||||||
let transaction = match connection.transaction() {
|
|
||||||
Ok(transaction) => transaction,
|
|
||||||
Err(e) => todo!("{e}"),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Begin migration
|
|
||||||
match migrate(&transaction) {
|
|
||||||
Ok(_) => {
|
|
||||||
// Confirm changes
|
|
||||||
match transaction.commit() {
|
|
||||||
Ok(_) => {} // @TODO
|
|
||||||
Err(e) => todo!("{e}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => todo!("{e}"),
|
|
||||||
}
|
|
||||||
} // unlock database
|
} // unlock database
|
||||||
|
|
||||||
// Start application
|
// Start application
|
||||||
self.application.run()
|
Ok(self.application.run())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
21
src/main.rs
21
src/main.rs
|
|
@ -8,8 +8,23 @@ use profile::Profile;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
match gtk::init() {
|
match Profile::new() {
|
||||||
Ok(_) => App::build(&Rc::new(Profile::new().unwrap())).run(),
|
Ok(profile) => {
|
||||||
Err(_) => ExitCode::FAILURE,
|
if let Err(e) = gtk::init() {
|
||||||
|
eprintln!("Failed to initialize GTK: {e}");
|
||||||
|
return ExitCode::FAILURE;
|
||||||
|
}
|
||||||
|
match App::build(&Rc::new(profile)).run() {
|
||||||
|
Ok(result) => result,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Failed to initialize application: {e}");
|
||||||
|
ExitCode::FAILURE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("Failed to initialize profile: {e}");
|
||||||
|
ExitCode::FAILURE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue