use crate::domain::IssueId;
use std::io;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("IO error: {0}")]
Io(#[from] io::Error),
#[error("Configuration error: {0}")]
Config(String),
#[error("Storage error: {0}")]
Storage(String),
#[error("Issue not found: {0}")]
IssueNotFound(IssueId),
#[error("Cannot delete {issue_id}: {dependent_count} other issue(s) depend on it. Dependents: {dependents:?}")]
HasDependents {
issue_id: IssueId,
dependent_count: usize,
dependents: Vec<IssueId>,
},
#[error(
"Circular dependency detected: adding dependency from {from} to {to} would create a cycle"
)]
CircularDependency {
from: IssueId,
to: IssueId,
},
#[error("Invalid issue ID format: {0}")]
InvalidIssueId(String),
#[error("Invalid priority value: {0} (must be 0-4)")]
InvalidPriority(u8),
#[error("Dependency not found: {from} -> {to}")]
DependencyNotFound {
from: IssueId,
to: IssueId,
},
#[error("Issue already exists: {0}")]
IssueAlreadyExists(IssueId),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
}
pub type Result<T> = std::result::Result<T, Error>;