create_lamdera_app_rs/
error.rs1use std::fmt;
2
3pub type Result<T> = anyhow::Result<T>;
4
5#[derive(Debug)]
6pub enum Error {
7 Io(std::io::Error),
8 InvalidProjectName(String),
9 GitCommandFailed(String),
10 GithubCommandFailed(String),
11 TemplateNotFound(String),
12 PackageManagerFailed(String),
13}
14
15impl fmt::Display for Error {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 Error::Io(e) => write!(f, "IO error: {}", e),
19 Error::InvalidProjectName(name) => write!(f, "Invalid project name: {}", name),
20 Error::GitCommandFailed(msg) => write!(f, "Git command failed: {}", msg),
21 Error::GithubCommandFailed(msg) => write!(f, "GitHub command failed: {}", msg),
22 Error::TemplateNotFound(path) => write!(f, "Template not found: {}", path),
23 Error::PackageManagerFailed(msg) => write!(f, "Package manager failed: {}", msg),
24 }
25 }
26}
27
28impl std::error::Error for Error {}
29
30impl From<std::io::Error> for Error {
31 fn from(err: std::io::Error) -> Self {
32 Error::Io(err)
33 }
34}