mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
tuple type for IoError
This commit is contained in:
parent
2b6c8b4296
commit
55a6f10d24
4 changed files with 10 additions and 16 deletions
|
@ -22,7 +22,7 @@ pub enum AnkiError {
|
|||
InvalidInput(String),
|
||||
TemplateError { info: String },
|
||||
TemplateSaveError { ordinal: usize },
|
||||
IoError { info: String },
|
||||
IoError(String),
|
||||
DbError(DbError),
|
||||
NetworkError(NetworkError),
|
||||
SyncError(SyncError),
|
||||
|
@ -96,9 +96,7 @@ pub enum TemplateError {
|
|||
|
||||
impl From<io::Error> for AnkiError {
|
||||
fn from(err: io::Error) -> Self {
|
||||
AnkiError::IoError {
|
||||
info: format!("{:?}", err),
|
||||
}
|
||||
AnkiError::IoError(format!("{:?}", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,9 +126,7 @@ impl From<prost::DecodeError> for AnkiError {
|
|||
|
||||
impl From<PathPersistError> for AnkiError {
|
||||
fn from(e: PathPersistError) -> Self {
|
||||
AnkiError::IoError {
|
||||
info: e.to_string(),
|
||||
}
|
||||
AnkiError::IoError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,9 +151,8 @@ where
|
|||
}
|
||||
|
||||
// add entry to the list
|
||||
let data = sha1_of_file(&dentry.path()).map_err(|e| AnkiError::IoError {
|
||||
info: format!("unable to read {}: {}", fname, e),
|
||||
})?;
|
||||
let data = sha1_of_file(&dentry.path())
|
||||
.map_err(|e| AnkiError::IoError(format!("unable to read {}: {}", fname, e)))?;
|
||||
let sha1 = Some(data);
|
||||
added_or_changed.push(FilesystemEntry {
|
||||
fname: fname.to_string(),
|
||||
|
|
|
@ -412,9 +412,10 @@ pub(super) fn data_for_file(media_folder: &Path, fname: &str) -> Result<Option<V
|
|||
if e.kind() == io::ErrorKind::NotFound {
|
||||
return Ok(None);
|
||||
} else {
|
||||
return Err(AnkiError::IoError {
|
||||
info: format!("unable to read {}: {}", fname, e),
|
||||
});
|
||||
return Err(AnkiError::IoError(format!(
|
||||
"unable to read {}: {}",
|
||||
fname, e
|
||||
)));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -682,9 +682,7 @@ impl Collection {
|
|||
// overwrite existing collection atomically
|
||||
out_file
|
||||
.persist(&col_path)
|
||||
.map_err(|e| AnkiError::IoError {
|
||||
info: format!("download save failed: {}", e),
|
||||
})?;
|
||||
.map_err(|e| AnkiError::IoError(format!("download save failed: {}", e)))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue