summaryrefslogtreecommitdiff
path: root/src/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.rs')
-rw-r--r--src/map.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/map.rs b/src/map.rs
index 1f693ac..2364941 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -1,3 +1,4 @@
+use std::error::Error;
use textwrap::fill;
pub use crate::from_yaml;
@@ -5,7 +6,7 @@ pub use crate::Status;
pub use crate::Step;
/// Error in Roadmap, from parsing or otherwise.
-pub type RoadmapError<T> = Result<T, String>;
+pub type RoadmapResult<T> = Result<T, Box<dyn Error>>;
/// Represent a full project roadmap.
///
@@ -117,12 +118,12 @@ impl Roadmap {
}
// Validate that the parsed, constructed roadmap is valid.
- pub fn validate(&self) -> RoadmapError<()> {
+ pub fn validate(&self) -> RoadmapResult<()> {
// Is there exactly one goal?
match self.count_goals() {
- 0 => return Err(format!("the roadmap doesn't have a goal")),
+ 0 => return Err(format!("the roadmap doesn't have a goal").into()),
1 => (),
- _ => return Err(format!("must have exactly one goal for roadmap")),
+ _ => return Err(format!("must have exactly one goal for roadmap").into()),
}
// Does every dependency exist?
@@ -134,7 +135,7 @@ impl Roadmap {
"step {} depends on missing {}",
step.name(),
depname
- ))
+ ).into())
}
Some(_) => (),
}
@@ -147,7 +148,7 @@ impl Roadmap {
/// Get a Graphviz dot language representation of a roadmap. This
/// is the textual representation, and the caller needs to use the
/// Graphviz dot(1) tool to create an image from it.
- pub fn format_as_dot(&self, label_width: usize) -> Result<String, Box<dyn std::error::Error>> {
+ pub fn format_as_dot(&self, label_width: usize) -> RoadmapResult<String> {
self.validate()?;
let labels = self.steps.iter().map(|step| {