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),
|
InvalidInput(String),
|
||||||
TemplateError { info: String },
|
TemplateError { info: String },
|
||||||
TemplateSaveError { ordinal: usize },
|
TemplateSaveError { ordinal: usize },
|
||||||
IoError { info: String },
|
IoError(String),
|
||||||
DbError(DbError),
|
DbError(DbError),
|
||||||
NetworkError(NetworkError),
|
NetworkError(NetworkError),
|
||||||
SyncError(SyncError),
|
SyncError(SyncError),
|
||||||
|
@ -96,9 +96,7 @@ pub enum TemplateError {
|
||||||
|
|
||||||
impl From<io::Error> for AnkiError {
|
impl From<io::Error> for AnkiError {
|
||||||
fn from(err: io::Error) -> Self {
|
fn from(err: io::Error) -> Self {
|
||||||
AnkiError::IoError {
|
AnkiError::IoError(format!("{:?}", err))
|
||||||
info: format!("{:?}", err),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,9 +126,7 @@ impl From<prost::DecodeError> for AnkiError {
|
||||||
|
|
||||||
impl From<PathPersistError> for AnkiError {
|
impl From<PathPersistError> for AnkiError {
|
||||||
fn from(e: PathPersistError) -> Self {
|
fn from(e: PathPersistError) -> Self {
|
||||||
AnkiError::IoError {
|
AnkiError::IoError(e.to_string())
|
||||||
info: e.to_string(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,9 +151,8 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// add entry to the list
|
// add entry to the list
|
||||||
let data = sha1_of_file(&dentry.path()).map_err(|e| AnkiError::IoError {
|
let data = sha1_of_file(&dentry.path())
|
||||||
info: format!("unable to read {}: {}", fname, e),
|
.map_err(|e| AnkiError::IoError(format!("unable to read {}: {}", fname, e)))?;
|
||||||
})?;
|
|
||||||
let sha1 = Some(data);
|
let sha1 = Some(data);
|
||||||
added_or_changed.push(FilesystemEntry {
|
added_or_changed.push(FilesystemEntry {
|
||||||
fname: fname.to_string(),
|
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 {
|
if e.kind() == io::ErrorKind::NotFound {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
} else {
|
} else {
|
||||||
return Err(AnkiError::IoError {
|
return Err(AnkiError::IoError(format!(
|
||||||
info: format!("unable to read {}: {}", fname, e),
|
"unable to read {}: {}",
|
||||||
});
|
fname, e
|
||||||
|
)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -682,9 +682,7 @@ impl Collection {
|
||||||
// overwrite existing collection atomically
|
// overwrite existing collection atomically
|
||||||
out_file
|
out_file
|
||||||
.persist(&col_path)
|
.persist(&col_path)
|
||||||
.map_err(|e| AnkiError::IoError {
|
.map_err(|e| AnkiError::IoError(format!("download save failed: {}", e)))?;
|
||||||
info: format!("download save failed: {}", e),
|
|
||||||
})?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue