use kanban_domain::KanbanError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum KanbanCliError {
#[error(transparent)]
Domain(#[from] KanbanError),
#[error("{hint}")]
Resolution { hint: String },
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Serialization(#[from] serde_json::Error),
}
pub type KanbanCliResult<T> = Result<T, KanbanCliError>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_from_kanban_error_lands_in_domain_variant() {
let domain = KanbanError::validation("bad input");
let cli: KanbanCliError = domain.into();
assert!(matches!(cli, KanbanCliError::Domain(_)));
}
#[test]
fn test_resolution_variant_displays_hint_verbatim() {
let err = KanbanCliError::Resolution {
hint: "no card matches 'foo'".into(),
};
assert!(err.to_string().contains("foo"));
}
#[test]
fn test_resolution_variant_display_has_no_prefix() {
let hint = "cycle detected: making KAN-5 a parent of KAN-7 would create a cycle";
let err = KanbanCliError::Resolution { hint: hint.into() };
assert_eq!(err.to_string(), hint);
}
}