use std::path::PathBuf;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, CrankError>;
#[derive(Error, Debug)]
pub enum CrankError {
#[error("Playdate SDK not found. Please install the SDK and set PLAYDATE_SDK_PATH environment variable.")]
SdkNotFound,
#[error("SDK component not found: {component}")]
SdkComponentNotFound { component: String },
#[error("Invalid project: {0}")]
InvalidProject(String),
#[error("Playdate.toml not found. Are you in a crank project directory?")]
ConfigNotFound,
#[error("Failed to parse Playdate.toml: {0}")]
ConfigParseError(String),
#[error("Build failed: {0}")]
BuildFailed(String),
#[error("Failed to launch simulator: {0}")]
SimulatorFailed(String),
#[error("Invalid project name: {0}. Project names must contain only alphanumeric characters and hyphens.")]
InvalidProjectName(String),
#[error("Project directory already exists: {0}")]
ProjectExists(PathBuf),
#[error("Template not found: {0}")]
TemplateNotFound(String),
#[error("File system error: {0}")]
IoError(#[from] std::io::Error),
#[error("TOML error: {0}")]
TomlError(#[from] toml::de::Error),
#[error("Watch error: {0}")]
WatchError(#[from] notify::Error),
#[error("Some tests failed")]
TestsFailed,
#[error("{0}")]
Other(String),
}
impl From<&str> for CrankError {
fn from(s: &str) -> Self {
CrankError::Other(s.to_string())
}
}
impl From<String> for CrankError {
fn from(s: String) -> Self {
CrankError::Other(s)
}
}