Files
jj-cz/src/error.rs

43 lines
1.2 KiB
Rust
Raw Normal View History

2026-02-09 20:55:40 +01:00
use crate::commit::types::{CommitMessageError, DescriptionError, ScopeError};
2026-02-05 19:37:36 +01:00
#[derive(Debug, thiserror::Error)]
pub enum Error {
// Domain errors
#[error("Invalid scope: {0}")]
InvalidScope(String),
#[error("Invalid description: {0}")]
InvalidDescription(String),
2026-02-09 20:55:40 +01:00
#[error("Invalid commit message: {0}")]
InvalidCommitMessage(String),
2026-02-05 19:37:36 +01:00
// Infrastructure errors
#[error("Not a Jujutsu repository")]
NotARepository,
2026-02-09 20:55:40 +01:00
#[error("Repository operation failed: {context}")]
JjOperation { context: String },
#[error("Repository is locked by another process")]
RepositoryLocked,
2026-02-05 19:37:36 +01:00
// Application errors
#[error("Operation cancelled by user")]
Cancelled,
#[error("Non-interactive terminal detected")]
NonInteractive,
2026-02-05 19:37:36 +01:00
}
2026-02-09 20:55:40 +01:00
impl From<ScopeError> for Error {
fn from(value: ScopeError) -> Self {
Self::InvalidScope(value.to_string())
}
}
impl From<DescriptionError> for Error {
fn from(value: DescriptionError) -> Self {
Self::InvalidDescription(value.to_string())
}
}
impl From<CommitMessageError> for Error {
fn from(value: CommitMessageError) -> Self {
Self::InvalidCommitMessage(value.to_string())
}
}