update error handlers

This commit is contained in:
yggverse 2024-10-06 00:49:43 +03:00
parent 271acd50ed
commit 5a22e73b50
5 changed files with 37 additions and 37 deletions

View file

@ -42,22 +42,22 @@ impl App {
// Init writable database connection // Init writable database connection
let mut connection = match profile_database_connection.write() { let mut connection = match profile_database_connection.write() {
Ok(connection) => connection, Ok(connection) => connection,
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}; };
// Init new transaction // Init new transaction
let transaction = match connection.transaction() { let transaction = match connection.transaction() {
Ok(transaction) => transaction, Ok(transaction) => transaction,
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}; };
// Init database structure // Init database structure
match Database::init(&transaction) { match Database::init(&transaction) {
Ok(database) => match transaction.commit() { Ok(database) => match transaction.commit() {
Ok(_) => Arc::new(database), Ok(_) => Arc::new(database),
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}, },
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
}; };
@ -149,13 +149,13 @@ impl App {
browser.restore(&transaction, &record.id); browser.restore(&transaction, &record.id);
} }
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
// Assign browser window to this application // Assign browser window to this application
@ -186,7 +186,7 @@ impl App {
// Delegate clean action to childs // Delegate clean action to childs
browser.clean(&transaction, &record.id); browser.clean(&transaction, &record.id);
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
@ -199,21 +199,21 @@ impl App {
&database.last_insert_id(&transaction), &database.last_insert_id(&transaction),
); );
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
// Confirm changes // Confirm changes
if let Err(error) = transaction.commit() { if let Err(e) = transaction.commit() {
todo!("{error}") todo!("{e}")
} }
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
}); });

View file

@ -53,22 +53,22 @@ impl Browser {
// Init writable database connection // Init writable database connection
let mut connection = match profile_database_connection.write() { let mut connection = match profile_database_connection.write() {
Ok(connection) => connection, Ok(connection) => connection,
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}; };
// Init new transaction // Init new transaction
let transaction = match connection.transaction() { let transaction = match connection.transaction() {
Ok(transaction) => transaction, Ok(transaction) => transaction,
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}; };
// Init database structure // Init database structure
match Database::init(&transaction) { match Database::init(&transaction) {
Ok(database) => match transaction.commit() { Ok(database) => match transaction.commit() {
Ok(_) => Arc::new(database), Ok(_) => Arc::new(database),
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}, },
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
}; };
@ -262,11 +262,11 @@ impl Browser {
self.widget.clean(tx, &record.id); self.widget.clean(tx, &record.id);
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
} }
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
} }
@ -282,7 +282,7 @@ impl Browser {
self.widget.restore(tx, &record.id); self.widget.restore(tx, &record.id);
} }
} }
Err(error) => panic!("{error}"), // @TODO Err(e) => todo!("{e}"),
} }
} }
@ -298,7 +298,7 @@ impl Browser {
self.widget.save(tx, &id); self.widget.save(tx, &id);
} }
Err(error) => panic!("{error}"), // @TODO Err(e) => todo!("{e}"),
} }
} }

View file

@ -28,22 +28,22 @@ impl Widget {
// Init writable database connection // Init writable database connection
let mut connection = match profile_database_connection.write() { let mut connection = match profile_database_connection.write() {
Ok(connection) => connection, Ok(connection) => connection,
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}; };
// Init new transaction // Init new transaction
let transaction = match connection.transaction() { let transaction = match connection.transaction() {
Ok(transaction) => transaction, Ok(transaction) => transaction,
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}; };
// Init database structure // Init database structure
match Database::init(&transaction) { match Database::init(&transaction) {
Ok(database) => match transaction.commit() { Ok(database) => match transaction.commit() {
Ok(_) => Arc::new(database), Ok(_) => Arc::new(database),
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
}, },
Err(error) => todo!("{error}"), Err(e) => todo!("{e}"),
} }
}; };
@ -73,11 +73,11 @@ impl Widget {
// Delegate clean action to childs // Delegate clean action to childs
// nothing yet.. // nothing yet..
} }
Err(error) => panic!("{error}"), // @TODO Err(e) => todo!("{e}"),
} }
} }
} }
Err(error) => panic!("{error}"), // @TODO Err(e) => todo!("{e}"),
} }
} }
@ -94,7 +94,7 @@ impl Widget {
// nothing yet.. // nothing yet..
} }
} }
Err(error) => panic!("{error}"), // @TODO Err(e) => todo!("{e}"),
} }
} }
@ -111,7 +111,7 @@ impl Widget {
// let id = self.database.last_insert_id(); // let id = self.database.last_insert_id();
// nothing yet.. // nothing yet..
} }
Err(error) => panic!("{error}"), // @TODO Err(e) => todo!("{e}"),
} }
} }

View file

@ -179,7 +179,7 @@ impl Page {
// Get host // Get host
let host = match uri.host() { let host = match uri.host() {
Some(host) => host, Some(host) => host,
None => panic!(), None => todo!(),
}; };
// Update // Update
@ -358,7 +358,7 @@ impl Page {
// Close connection // Close connection
if let Err(e) = connection.close(Some(&cancellable)) { if let Err(e) = connection.close(Some(&cancellable)) {
panic!("Error closing connection: {:?}", e); todo!("Error closing connection: {:?}", e);
} }
} }
Err(e) => { Err(e) => {
@ -371,7 +371,7 @@ impl Page {
// Close connection // Close connection
if let Err(e) = connection.close(Some(&cancellable)) { if let Err(e) = connection.close(Some(&cancellable)) {
panic!("Error closing response connection: {:?}", e); todo!("Error closing response connection: {:?}", e);
} }
} }
}, },
@ -387,7 +387,7 @@ impl Page {
// Close connection // Close connection
if let Err(e) = connection.close(Some(&cancellable)) { if let Err(e) = connection.close(Some(&cancellable)) {
panic!("Error closing request connection: {:?}", e); todo!("Error closing request connection: {:?}", e);
} }
} }
}, },

View file

@ -20,8 +20,8 @@ fn main() -> ExitCode {
profile_path.push(APP_ID); profile_path.push(APP_ID);
profile_path.push(BRANCH); profile_path.push(BRANCH);
if let Err(error) = create_dir_all(&profile_path) { if let Err(e) = create_dir_all(&profile_path) {
panic!("Failed to create profile directory: {error}") panic!("Failed to create profile directory: {e}")
} }
// Init profile database path // Init profile database path
@ -32,7 +32,7 @@ fn main() -> ExitCode {
// Init database connection // Init database connection
let profile_database_connection = match Connection::open(profile_database_path) { let profile_database_connection = match Connection::open(profile_database_path) {
Ok(connection) => Arc::new(RwLock::new(connection)), Ok(connection) => Arc::new(RwLock::new(connection)),
Err(error) => panic!("Failed to connect profile database: {error}"), Err(e) => panic!("Failed to connect profile database: {e}"),
}; };
// Init GTK, start application // Init GTK, start application