1use thiserror::Error;
8
9#[derive(Error, Debug)]
11pub enum NapError {
12 #[error("invalid NAP URI '{uri}': {reason}")]
14 InvalidUri { uri: String, reason: String },
15
16 #[error("manifest not found: {0}")]
18 ManifestNotFound(String),
19
20 #[error("manifest parse error for '{path}': {source}")]
21 ManifestParseError {
22 path: String,
23 source: serde_yaml::Error,
24 },
25
26 #[error("manifest validation error: {0}")]
27 ManifestValidationError(String),
28
29 #[error("manifest write error for '{path}': {source}")]
30 ManifestWriteError {
31 path: String,
32 source: std::io::Error,
33 },
34
35 #[error("query path not found: '{path}' in manifest '{manifest_id}'")]
37 QueryPathNotFound { path: String, manifest_id: String },
38
39 #[error("invalid query path: '{0}'")]
40 InvalidQueryPath(String),
41
42 #[error("repository not found at '{0}'")]
44 RepositoryNotFound(String),
45
46 #[error("repository already exists at '{0}'")]
47 RepositoryAlreadyExists(String),
48
49 #[error("entity type not found: '{0}'")]
51 EntityTypeNotFound(String),
52
53 #[error("VCS error: {0}")]
55 VcsError(String),
56
57 #[error("ref not found: '{0}'")]
58 RefNotFound(String),
59
60 #[error(
62 "cannot {operation}: no version-control backend is configured. \
63 Filesystem state is preserved, but history/sync is unavailable. \
64 Configure one with 'nap backend configure'."
65 )]
66 BackendNotConfigured { operation: String },
67
68 #[error("version-control backend is unavailable: {message}")]
69 BackendUnavailable { message: String },
70
71 #[error("version-control backend operation failed ({operation}): {message}")]
72 BackendOperationFailed { operation: String, message: String },
73
74 #[error("content hash mismatch: expected {expected}, got {actual}")]
76 ContentHashMismatch { expected: String, actual: String },
77
78 #[error("I/O error: {0}")]
80 Io(#[from] std::io::Error),
81
82 #[error("merge conflict at '{path}': {details}")]
84 MergeConflict { path: String, details: String },
85
86 #[error("SDL parse error: {0}")]
87 SdlParseError(String),
88
89 #[error("SDL validation error: {reason}")]
90 SdlValidationError { reason: String },
91
92 #[error("merge strategy error at '{path}': {reason}")]
93 MergeStrategyError { path: String, reason: String },
94
95 #[error("merge validation error: {reason}")]
96 MergeValidationError { reason: String },
97
98 #[error("no branch or commit specified and no default_branch configured. ")]
100 NoDefaultBranch,
101
102 #[error("unable to resolve resource '{address}': {message}")]
103 ResolutionFailed { address: String, message: String },
104
105 #[error("permission denied: {0}")]
107 PermissionDenied(String),
108
109 #[error("gRPC error: {0}")]
111 GrpcError(String),
112
113 #[error("{0}")]
115 Other(String),
116}
117
118pub type NapResult<T> = Result<T, NapError>;