Files
jj-cz/src/error.rs
Lucien Cartier-Tilet e28f1fdbe1
Some checks failed
Publish Docker Images / coverage-and-sonar (push) Failing after 16m33s
feat(errors): preserve jj-emitted errors when loading config
2026-04-05 15:56:24 +02:00

53 lines
1.5 KiB
Rust

use crate::commit::types::{CommitMessageError, DescriptionError, ScopeError};
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum Error {
// Domain errors
#[error("Invalid scope: {0}")]
InvalidScope(String),
#[error("Invalid description: {0}")]
InvalidDescription(String),
#[error("Invalid commit message: {0}")]
InvalidCommitMessage(String),
// Infrastructure errors
#[error("Not a Jujutsu repository")]
NotARepository,
#[error("Repository operation failed: {context}")]
JjOperation { context: String },
#[error("Repository is locked by another process")]
RepositoryLocked,
#[error("Could not get current directory")]
FailedGettingCurrentDir,
#[error("Could not load Jujutsu configuration: {context}")]
FailedReadingConfig { context: String },
// Application errors
#[error("Operation cancelled by user")]
Cancelled,
#[error("Non-interactive terminal detected")]
NonInteractive,
}
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())
}
}
impl From<std::io::Error> for Error {
fn from(_value: std::io::Error) -> Self {
Self::FailedGettingCurrentDir
}
}