Introduce MaybeError type
This commit is contained in:
1 parent
d836b57d2a
commit
a60ed37cd4
16 files changed
+127
-93
No files matched your search
@@ -1,5 +1,5 @@
|
||||
use crate::data::entities::{CardStatistics, DeckSettings};
|
||||
use crate::notification::NotificationData;
|
||||
use crate::notification::{MaybeError, NotificationData};
|
||||
use crate::notification::NotificationData::{DbLoadError, DbSaveError};
|
||||
use log::info;
|
||||
use rusqlite::{Connection, params};
|
||||
@@ -30,7 +30,7 @@ pub fn load_stats_of_deck(
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
pub fn add_stat_list(stats: &mut [CardStatistics], connection: &mut Connection) -> Result<(), NotificationData> {
|
||||
pub fn add_stat_list(stats: &mut [CardStatistics], connection: &mut Connection) -> MaybeError {
|
||||
let time = Instant::now();
|
||||
let tx = connection.transaction().expect("Failed to create transaction");
|
||||
let count = stats.len();
|
||||
@@ -66,7 +66,7 @@ pub fn add_stat_list(stats: &mut [CardStatistics], connection: &mut Connection)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn update_stat_score(stat: &CardStatistics, connection: &Connection) -> Result<(), NotificationData> {
|
||||
pub fn update_stat_score(stat: &CardStatistics, connection: &Connection) -> MaybeError {
|
||||
let time = Instant::now();
|
||||
|
||||
connection
|
||||
@@ -79,7 +79,7 @@ pub fn update_stat_score(stat: &CardStatistics, connection: &Connection) -> Resu
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn delete_stats(stat: &[CardStatistics], connection: &Connection) -> Result<(), NotificationData> {
|
||||
pub fn delete_stats(stat: &[CardStatistics], connection: &Connection) -> MaybeError {
|
||||
if stat.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user