summaryrefslogtreecommitdiff
path: root/src/generation.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-24 08:18:56 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-29 10:51:31 +0300
commit80ae98bf87c57aa361a13c3dd925455fb67e3f03 (patch)
treeaca3860996a6ebd622802d6a41493008189203ab /src/generation.rs
parentbf645f3645fd2ee57495eafd1ccfb4afbe917bec (diff)
downloadobnam2-80ae98bf87c57aa361a13c3dd925455fb67e3f03.tar.gz
feat: improve error messages
All unclear error messages should now be clearer. For example, all the ones related to a file mention the file name and the attempted operation that failed.
Diffstat (limited to 'src/generation.rs')
-rw-r--r--src/generation.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/generation.rs b/src/generation.rs
index 0055bfe..85af1f5 100644
--- a/src/generation.rs
+++ b/src/generation.rs
@@ -27,11 +27,11 @@ pub enum NascentError {
#[error(transparent)]
BackupError(#[from] BackupError),
- #[error(transparent)]
- RusqliteError(#[from] rusqlite::Error),
+ #[error("SQL transaction error: {0}")]
+ Transaction(rusqlite::Error),
- #[error(transparent)]
- IoError(#[from] std::io::Error),
+ #[error("SQL commit error: {0}")]
+ Commit(rusqlite::Error),
}
pub type NascentResult<T> = Result<T, NascentError>;
@@ -55,10 +55,10 @@ impl NascentGeneration {
ids: &[ChunkId],
reason: Reason,
) -> NascentResult<()> {
- let t = self.conn.transaction()?;
+ let t = self.conn.transaction().map_err(NascentError::Transaction)?;
self.fileno += 1;
sql::insert_one(&t, e, self.fileno, ids, reason)?;
- t.commit()?;
+ t.commit().map_err(NascentError::Commit)?;
Ok(())
}
@@ -66,7 +66,7 @@ impl NascentGeneration {
&mut self,
entries: impl Iterator<Item = BackupResult<(FilesystemEntry, Vec<ChunkId>, Reason)>>,
) -> NascentResult<Vec<BackupError>> {
- let t = self.conn.transaction()?;
+ let t = self.conn.transaction().map_err(NascentError::Transaction)?;
let mut warnings = vec![];
for r in entries {
match r {
@@ -80,7 +80,7 @@ impl NascentGeneration {
}
}
}
- t.commit()?;
+ t.commit().map_err(NascentError::Commit)?;
Ok(warnings)
}
}