error issues

This commit is contained in:
ssrlive 2023-09-24 23:18:42 +08:00
parent 53daaed385
commit 8adfd8a0c1
2 changed files with 12 additions and 3 deletions

View file

@ -6,7 +6,7 @@ pub enum Error {
#[error("ctrlc::Error {0:?}")]
InterruptHandler(#[from] ctrlc::Error),
#[error("std::io::Error {0}")]
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("TryFromIntError {0:?}")]
@ -84,4 +84,13 @@ impl From<&String> for Error {
}
}
impl From<Error> for std::io::Error {
fn from(err: Error) -> Self {
match err {
Error::Io(err) => err,
_ => std::io::Error::new(std::io::ErrorKind::Other, err),
}
}
}
pub type Result<T, E = Error> = std::result::Result<T, E>;