feat(errors): update error types
This commit is contained in:
30
src/error.rs
30
src/error.rs
@@ -1,3 +1,5 @@
|
|||||||
|
use crate::commit::types::{CommitMessageError, DescriptionError, ScopeError};
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
// Domain errors
|
// Domain errors
|
||||||
@@ -5,16 +7,36 @@ pub enum Error {
|
|||||||
InvalidScope(String),
|
InvalidScope(String),
|
||||||
#[error("Invalid description: {0}")]
|
#[error("Invalid description: {0}")]
|
||||||
InvalidDescription(String),
|
InvalidDescription(String),
|
||||||
|
#[error("Invalid commit message: {0}")]
|
||||||
|
InvalidCommitMessage(String),
|
||||||
// Infrastructure errors
|
// Infrastructure errors
|
||||||
#[error("Not a Jujutsu repository")]
|
#[error("Not a Jujutsu repository")]
|
||||||
NotARepository,
|
NotARepository,
|
||||||
#[error("jj is not installed or not in PATH")]
|
#[error("Repository operation failed: {context}")]
|
||||||
JjNotFound,
|
JjOperation { context: String },
|
||||||
#[error("jj command failed: {message}")]
|
#[error("Repository is locked by another process")]
|
||||||
JjCommand { message: String, stderr: String },
|
RepositoryLocked,
|
||||||
// Application errors
|
// Application errors
|
||||||
#[error("Operation cancelled by user")]
|
#[error("Operation cancelled by user")]
|
||||||
Cancelled,
|
Cancelled,
|
||||||
#[error("Non-interactive terminal detected")]
|
#[error("Non-interactive terminal detected")]
|
||||||
NonInteractive,
|
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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user