Introduce MaybeError type

This commit is contained in:
micialware committed 2026-08-24 23:42:58 +03:00
1 parent d836b57d2a
commit a60ed37cd4
16 files changed
+127 -93

No files matched your search

+9 -9
View File
@@ -5,19 +5,19 @@ pub fn create_db() {
let db_file = db_path();
if !db_file.exists() {
std::fs::File::create(&db_file).expect("Database file creation failed");
let connection = Connection::open(&db_file).unwrap();
connection.execute("PRAGMA foreign_keys = ON;", []).unwrap();
let connection = Connection::open(&db_file).expect("Connection open failed");
connection.execute("PRAGMA foreign_keys = ON;", []).expect("Failed to set PRAGMA");
create_tables(&connection);
}
}
fn create_tables(conn: &Connection) {
make_card_set(conn).unwrap();
make_settings(conn).unwrap();
make_word_group(conn).unwrap();
make_words(conn).unwrap();
make_card_stats(conn).unwrap();
make_card_set(conn).expect("Failed to init table");
make_settings(conn).expect("Failed to init table");
make_word_group(conn).expect("Failed to init table");
make_words(conn).expect("Failed to init table");
make_card_stats(conn).expect("Failed to init table");
}
fn make_settings(conn: &Connection) -> Result<(), rusqlite::Error> {
@@ -51,7 +51,7 @@ fn make_card_stats(conn: &Connection) -> Result<(), rusqlite::Error> {
pub fn default_connection() -> Connection {
let db_file = db_path();
let connection = Connection::open(db_file).unwrap();
connection.execute("PRAGMA foreign_keys = ON;", []).unwrap();
let connection = Connection::open(db_file).expect("Failed to open database");
connection.execute("PRAGMA foreign_keys = ON;", []).expect("Failed to set PRAGMA");
connection
}