69 lines
2.1 KiB
Rust
69 lines
2.1 KiB
Rust
use crate::region::RegionParseError;
|
|
|
|
pub type Result<T> = std::result::Result<T, AlbatrossError>;
|
|
|
|
#[derive(Debug)]
|
|
pub enum AlbatrossError {
|
|
FileError(std::io::Error),
|
|
SSHError(ssh2::Error),
|
|
ChunkParseError(crate::chunk_coordinate::ChunkCoordinateErr),
|
|
RegionParseError(crate::region::RegionParseError),
|
|
ChronoParseError(chrono::ParseError),
|
|
NoSSHAuth,
|
|
FTPError(ftp::FtpError),
|
|
}
|
|
|
|
impl std::error::Error for AlbatrossError {}
|
|
|
|
impl std::fmt::Display for AlbatrossError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
AlbatrossError::FileError(e) => write!(f, "File I/O error: {}", e),
|
|
AlbatrossError::SSHError(e) => write!(f, "SSH error: {}", e),
|
|
AlbatrossError::ChunkParseError(e) => {
|
|
write!(f, "Unable to parse chunk coordinate: {}", e)
|
|
}
|
|
AlbatrossError::RegionParseError(e) => write!(f, "Unable to parse region name: {}", e),
|
|
AlbatrossError::ChronoParseError(e) => write!(f, "Unable to parse time: {}", e),
|
|
AlbatrossError::NoSSHAuth => write!(f, "No SSH auth methods provided in the config"),
|
|
AlbatrossError::FTPError(e) => write!(f, "FTP error: {}", e),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<std::io::Error> for AlbatrossError {
|
|
fn from(e: std::io::Error) -> Self {
|
|
AlbatrossError::FileError(e)
|
|
}
|
|
}
|
|
|
|
impl From<ssh2::Error> for AlbatrossError {
|
|
fn from(e: ssh2::Error) -> Self {
|
|
AlbatrossError::SSHError(e)
|
|
}
|
|
}
|
|
|
|
impl From<crate::chunk_coordinate::ChunkCoordinateErr> for AlbatrossError {
|
|
fn from(e: crate::chunk_coordinate::ChunkCoordinateErr) -> Self {
|
|
AlbatrossError::ChunkParseError(e)
|
|
}
|
|
}
|
|
|
|
impl From<crate::region::RegionParseError> for AlbatrossError {
|
|
fn from(e: RegionParseError) -> Self {
|
|
AlbatrossError::RegionParseError(e)
|
|
}
|
|
}
|
|
|
|
impl From<chrono::ParseError> for AlbatrossError {
|
|
fn from(e: chrono::ParseError) -> Self {
|
|
AlbatrossError::ChronoParseError(e)
|
|
}
|
|
}
|
|
|
|
impl From<ftp::FtpError> for AlbatrossError {
|
|
fn from(e: ftp::FtpError) -> Self {
|
|
AlbatrossError::FTPError(e)
|
|
}
|
|
}
|