summaryrefslogtreecommitdiff
path: root/src/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 7da2254..7602b94 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -3,6 +3,7 @@ use serde_yaml::Value;
use std::collections::HashMap;
pub use crate::Roadmap;
+pub use crate::RoadmapError;
pub use crate::RoadmapResult;
pub use crate::Status;
pub use crate::Step;
@@ -37,7 +38,7 @@ fn step_from_value(name: &str, value: &Value) -> RoadmapResult<Step> {
Ok(step)
}
- _ => Err("step is not a mapping".to_string().into()),
+ _ => Err(RoadmapError::StepNotMapping),
}
}
@@ -46,19 +47,18 @@ fn parse_depends(map: &Value) -> RoadmapResult<Vec<&str>> {
let key_name = "depends";
let key = Value::String(key_name.to_string());
let mut depends: Vec<&str> = vec![];
- let need_list_of_names = format!("'depends' must be a list of step names");
-
+
match map.get(&key) {
None => (),
Some(Value::Sequence(deps)) => {
for depname in deps.iter() {
match depname {
Value::String(depname) => depends.push(depname),
- _ => return Err(need_list_of_names.into()),
+ _ => return Err(RoadmapError::DependsNotNames),
}
}
}
- _ => return Err(need_list_of_names.into()),
+ _ => return Err(RoadmapError::DependsNotNames),
}
Ok(depends)
@@ -74,7 +74,7 @@ fn parse_status<'a>(map: &'a Value) -> RoadmapResult<Status> {
let text = parse_string("status", map);
match Status::from_text(text) {
Some(status) => Ok(status),
- _ => Err(format!("unknown status: {:?}", text).into()),
+ _ => Err(RoadmapError::UnknownStatus(text.into())),
}
}