diff options
Diffstat (limited to 'src/map.rs')
-rw-r--r-- | src/map.rs | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -1,12 +1,12 @@ -use std::error::Error; use textwrap::fill; pub use crate::from_yaml; +pub use crate::RoadmapError; pub use crate::Status; pub use crate::Step; /// Error in Roadmap, from parsing or otherwise. -pub type RoadmapResult<T> = Result<T, Box<dyn Error>>; +pub type RoadmapResult<T> = Result<T, RoadmapError>; /// Represent a full project roadmap. /// @@ -131,14 +131,14 @@ impl Roadmap { let goals = self.goals(); let n = goals.len(); match n { - 0 => return Err(format!("the roadmap doesn't have a goal").into()), + 0 => return Err(RoadmapError::NoGoals), 1 => (), _ => { - let mut names: Vec<&str> = goals.iter().map(|s| s.name()).collect(); - names.sort(); - let names = names.join(", "); - let msg = format!("only one goal allowed, found {}: {}", n, names); - return Err(msg.into()); + let names: Vec<String> = goals.iter().map(|s| s.name().into()).collect(); + return Err(RoadmapError::ManyGoals { + count: n, + names: names, + }); } } @@ -146,11 +146,11 @@ impl Roadmap { for step in self.iter() { for depname in step.dependencies() { match self.get_step(depname) { - None => { - return Err( - format!("step {} depends on missing {}", step.name(), depname).into(), - ) - } + None => + return Err(RoadmapError::MissingDep { + name: step.name().into(), + missing: depname.into(), + }), Some(_) => (), } } |