use thiserror::Error;
#[derive(Debug, Error)]
pub enum AppError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Parse error in {file}: {reason}")]
Parse { file: String, reason: String },
#[error("{0}")]
InvalidInput(String),
#[error("State error: {0}")]
State(String),
#[error("Platform not supported: {0}")]
PlatformUnsupported(String),
#[error("Analysis failed: {0}")]
Analysis(String),
#[error("{0}")]
Internal(String),
}
impl From<AppError> for tauri::ipc::InvokeError {
fn from(err: AppError) -> Self {
tauri::ipc::InvokeError::from(err.to_string())
}
}
impl From<String> for AppError {
fn from(s: String) -> Self {
AppError::Internal(s)
}
}
impl From<&str> for AppError {
fn from(s: &str) -> Self {
AppError::Internal(s.to_string())
}
}
pub type CmdResult<T> = Result<T, AppError>;