1use std::path::PathBuf;
8
9pub type Result<T> = std::result::Result<T, Error>;
10
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13 #[error("Could not determine config directory")]
14 NoConfigDir,
15
16 #[error("Project '{0}' already exists")]
17 ProjectExists(String),
18
19 #[error("Project '{0}' not found")]
20 ProjectNotFound(String),
21
22 #[error("Path not found: {0}")]
23 PathNotFound(PathBuf),
24
25 #[error("Path is not a git/jj repository: {0}")]
26 NotVcsRepo(PathBuf),
27
28 #[error("Path does not belong to any registered project: {0}")]
29 NoProjectForPath(PathBuf),
30
31 #[error("No project detected (not registered and no .grove/config.toml found)")]
32 NoProjectDetected,
33
34 #[error("Invalid KEY=value format: {0}")]
35 InvalidEnvFormat(String),
36
37 #[error("VCS command failed: {0}")]
38 VcsCommandFailed(String),
39
40 #[error("jj is not installed but this project uses jj workspaces (.jj directory found). Install jj or use --vcs git to force git mode")]
41 JjNotInstalled,
42
43 #[error("Unknown VCS backend '{0}'. Supported: git")]
44 InvalidVcsOverride(String),
45
46 #[error("Worktree path already exists: {0}")]
47 WorktreePathExists(PathBuf),
48
49 #[error("Worktree '{0}' not found")]
50 WorktreeNotFound(String),
51
52 #[error("Invalid worktree name '{0}': must contain only alphanumeric characters, hyphens, and underscores")]
53 InvalidWorktreeName(String),
54
55 #[error("Ambiguous worktree name '{0}', could match: {1}")]
56 AmbiguousWorktreeName(String, String),
57
58 #[error("Invalid project reference '{0}': expected 'project' or 'project/worktree'")]
59 InvalidProjectRef(String),
60
61 #[error("Worktree '{1}' not found in project '{0}'")]
62 WorktreeEnvNotFound(String, String),
63
64 #[error(transparent)]
65 Io(#[from] std::io::Error),
66
67 #[error(transparent)]
68 TomlDeserialize(#[from] toml::de::Error),
69
70 #[error(transparent)]
71 TomlSerialize(#[from] toml::ser::Error),
72
73 #[error(transparent)]
74 SerdeJson(#[from] serde_json::Error),
75
76 #[error("Could not determine data directory for mise plugin installation")]
77 NoDataDir,
78
79 #[error("Failed to create database: {0}")]
80 DatabaseCreationFailed(String),
81
82 #[error("Failed to drop database: {0}")]
83 DatabaseDropFailed(String),
84
85 #[error("Setup command failed: {0}")]
86 SetupCommandFailed(String),
87
88 #[error("Post-create hook failed: `{0}`\n{1}")]
89 HookFailed(String, String),
90
91 #[error("Editor '{0}' exited with status {1}")]
92 EditorFailed(String, String),
93}