pakker/src/error.rs
NotAShelf ef28bdaeb4
initial commit
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ife1391ed23a1e7f388b1b5eca90b9ea76a6a6964
2026-02-13 00:14:46 +03:00

110 lines
2.3 KiB
Rust

use thiserror::Error;
pub type Result<T> = std::result::Result<T, PakkerError>;
#[derive(Error, Debug)]
pub enum PakkerError {
// Network errors
#[error("Network request failed: {0}")]
NetworkError(#[from] reqwest::Error),
#[error("Platform API error: {0}")]
PlatformApiError(String),
// Validation errors
#[error("Invalid lock file: {0}")]
InvalidLockFile(String),
#[error("Invalid config file: {0}")]
InvalidConfigFile(String),
#[error("Project not found: {0}")]
ProjectNotFound(String),
#[error("File selection error: {0}")]
FileSelectionError(String),
#[error("File not found: {0}")]
FileNotFound(String),
// Conflict errors
#[error("Circular dependency detected: {0}")]
CircularDependency(String),
// File I/O errors
#[error("IO error: {0}")]
IoError(#[from] std::io::Error),
#[error("Serialization error: {0}")]
SerializationError(#[from] serde_json::Error),
#[error("Hash mismatch for file {file}: expected {expected}, got {actual}")]
HashMismatch {
file: String,
expected: String,
actual: String,
},
#[error("Download failed: {0}")]
DownloadFailed(String),
// Export errors
#[error("Export failed: {0}")]
ExportFailed(String),
#[error("Invalid export profile: {0}")]
InvalidExportProfile(String),
// General errors
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("Internal error: {0}")]
InternalError(String),
#[error("Already exists: {0}")]
AlreadyExists(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("Invalid project: {0}")]
InvalidProject(String),
#[error("Invalid import file: {0}")]
InvalidImportFile(String),
#[error("Zip error: {0}")]
ZipError(#[from] zip::result::ZipError),
// Git and Fork errors
#[error("Git error: {0}")]
GitError(String),
#[error("Remote not found: {0}")]
RemoteNotFound(String),
#[error("Fork error: {0}")]
Fork(String),
#[error("Invalid hash: {0}")]
InvalidHash(String),
#[error("Invalid response: {0}")]
InvalidResponse(String),
#[error("IPC error: {0}")]
IpcError(String),
}
impl From<git2::Error> for PakkerError {
fn from(err: git2::Error) -> Self {
Self::GitError(err.to_string())
}
}
impl From<crate::ipc::IpcError> for PakkerError {
fn from(err: crate::ipc::IpcError) -> Self {
Self::IpcError(err.to_string())
}
}