cuenv_task_graph/
error.rs1use std::fmt;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, Clone)]
10pub enum Error {
11 CycleDetected {
13 message: String,
15 },
16
17 MissingDependency {
19 task: String,
21 dependency: String,
23 },
24
25 MissingDependencies {
27 missing: Vec<(String, String)>,
29 },
30
31 TopologicalSortFailed {
33 reason: String,
35 },
36}
37
38impl fmt::Display for Error {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 match self {
41 Self::CycleDetected { message } => {
42 write!(f, "Cycle detected in task graph: {message}")
43 }
44 Self::MissingDependency { task, dependency } => {
45 write!(f, "Task '{task}' depends on missing task '{dependency}'")
46 }
47 Self::MissingDependencies { missing } => {
48 let list = missing
49 .iter()
50 .map(|(task, dep)| format!("Task '{task}' depends on missing task '{dep}'"))
51 .collect::<Vec<_>>()
52 .join(", ");
53 write!(f, "Missing dependencies: {list}")
54 }
55 Self::TopologicalSortFailed { reason } => {
56 write!(f, "Failed to sort tasks topologically: {reason}")
57 }
58 }
59 }
60}
61
62impl std::error::Error for Error {}