From 0bb9471477b1c23664d3a2c46242feaa8d357553 Mon Sep 17 00:00:00 2001 From: kdesjard Date: Tue, 12 Dec 2023 11:36:43 +0000 Subject: [PATCH] convert an unwrap to use ParseError Signed-off-by: kdesjard --- src/yaml/yaml_parser.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yaml/yaml_parser.rs b/src/yaml/yaml_parser.rs index cda037e..8e1076f 100644 --- a/src/yaml/yaml_parser.rs +++ b/src/yaml/yaml_parser.rs @@ -1,6 +1,6 @@ //! Default yaml configuration file parser. -use super::{FileContentError, FileNotFound, YamlTask, YamlTaskError}; +use super::{FileContentError, YamlTask, YamlTaskError}; use crate::{utils::ParseError, Action, CommandAction, Parser, Task, utils::file::load_file}; use std::{collections::HashMap, sync::Arc}; use yaml_rust::{Yaml, YamlLoader}; @@ -81,7 +81,7 @@ impl Parser for YamlParser { let mut map = HashMap::with_capacity(yaml_tasks.len()); // Read tasks for (v, w) in yaml_tasks { - let id = v.as_str().unwrap(); + let id = v.as_str().ok_or(ParseError("Invalid YAML Node Type".to_string()))?; let task = specific_actions.remove(id).map_or_else( || self.parse_one(id, w, None), |action| self.parse_one(id, w, Some(action)),