#[derive(Debug, thiserror::Error)] pub enum SshError { #[error("authentication rejected: {0}")] AuthRejected(String), #[error("failed to load host key: {0}")] KeyLoadFailed(String), #[error("repository not found: {0}")] RepoNotFound(String), #[error("permission denied: {0}")] PermissionDenied(String), #[error("invalid command: {0}")] InvalidCommand(String), #[error("io error: {0}")] Io(#[from] std::io::Error), #[error("database error: {0}")] Db(#[from] sea_orm::DbErr), #[error("ssh error: {0}")] Ssh(#[from] russh::Error), #[error("internal error: {0}")] Internal(String), } pub type SshResult = Result; impl From for SshError { fn from(err: crate::smart::error::SmartError) -> Self { use crate::smart::error::SmartError; match err { SmartError::Unauthorized => Self::AuthRejected("authentication required".into()), SmartError::BadRequest(m) => Self::InvalidCommand(m), SmartError::Conflict(m) => Self::Internal(m), SmartError::Forbidden(m) => Self::PermissionDenied(m), SmartError::NotFound(m) => Self::RepoNotFound(m), SmartError::Internal(m) => Self::Internal(m), SmartError::Io(e) => Self::Io(e), SmartError::Db(e) => Self::Db(e), SmartError::Redis(e) => Self::Internal(format!("redis error: {e}")), } } }