use thiserror::Error;
#[derive(Error, Debug)]
pub enum NapError {
#[error("invalid NAP URI '{uri}': {reason}")]
InvalidUri { uri: String, reason: String },
#[error("manifest not found: {0}")]
ManifestNotFound(String),
#[error("manifest parse error for '{path}': {source}")]
ManifestParseError {
path: String,
source: serde_yaml::Error,
},
#[error("manifest validation error: {0}")]
ManifestValidationError(String),
#[error("manifest write error for '{path}': {source}")]
ManifestWriteError {
path: String,
source: std::io::Error,
},
#[error("query path not found: '{path}' in manifest '{manifest_id}'")]
QueryPathNotFound { path: String, manifest_id: String },
#[error("invalid query path: '{0}'")]
InvalidQueryPath(String),
#[error("repository not found at '{0}'")]
RepositoryNotFound(String),
#[error(
"operation requires a local NAP working tree for '{repository}'; use 'nap pull {repository}' first"
)]
LocalWorkingTreeRequired { repository: String },
#[error("repository already exists at '{0}'")]
RepositoryAlreadyExists(String),
#[error("entity type not found: '{0}'")]
EntityTypeNotFound(String),
#[error("VCS error: {0}")]
VcsError(String),
#[error("ref not found: '{0}'")]
RefNotFound(String),
#[error(
"cannot {operation}: no version-control backend is configured. \
Filesystem state is preserved, but history/sync is unavailable. \
Configure one with 'nap backend configure'."
)]
BackendNotConfigured { operation: String },
#[error("version-control backend is unavailable: {message}")]
BackendUnavailable { message: String },
#[error("version-control backend operation failed ({operation}): {message}")]
BackendOperationFailed { operation: String, message: String },
#[error("content hash mismatch: expected {expected}, got {actual}")]
ContentHashMismatch { expected: String, actual: String },
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("merge conflict at '{path}': {details}")]
MergeConflict { path: String, details: String },
#[error("SDL parse error: {0}")]
SdlParseError(String),
#[error("SDL validation error: {reason}")]
SdlValidationError { reason: String },
#[error("merge strategy error at '{path}': {reason}")]
MergeStrategyError { path: String, reason: String },
#[error("merge validation error: {reason}")]
MergeValidationError { reason: String },
#[error("no branch or commit specified and no default_branch configured. ")]
NoDefaultBranch,
#[error("unable to resolve resource '{address}': {message}")]
ResolutionFailed { address: String, message: String },
#[error("permission denied: {0}")]
PermissionDenied(String),
#[error("gRPC error: {0}")]
GrpcError(String),
#[error("{0}")]
Other(String),
}
pub type NapResult<T> = Result<T, NapError>;