From 339b199ee329301856683fa5a1170f70fb343d97 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 29 Mar 2024 23:00:07 +0900 Subject: [PATCH] templater: merge ParseIntError into generic Expression error It was only needed to attach the source error object, which is now handled by the outer error type. --- cli/src/template_parser.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cli/src/template_parser.rs b/cli/src/template_parser.rs index 5bf45f06c..8c42717a0 100644 --- a/cli/src/template_parser.rs +++ b/cli/src/template_parser.rs @@ -75,8 +75,6 @@ pub struct TemplateParseError { pub enum TemplateParseErrorKind { #[error("Syntax error")] SyntaxError, - #[error("Invalid integer literal")] - ParseIntError, #[error(r#"Keyword "{name}" doesn't exist"#)] NoSuchKeyword { name: String, @@ -405,8 +403,7 @@ fn parse_term_node(pair: Pair) -> TemplateParseResult { } Rule::integer_literal => { let value = expr.as_str().parse().map_err(|err| { - TemplateParseError::with_span(TemplateParseErrorKind::ParseIntError, span) - .with_source(err) + TemplateParseError::expression("Invalid integer literal", span).with_source(err) })?; ExpressionNode::new(ExpressionKind::Integer(value), span) } @@ -1229,7 +1226,7 @@ mod tests { ); assert_matches!( parse_into_kind(&format!("{}", (i64::MAX as u64) + 1)), - Err(TemplateParseErrorKind::ParseIntError) + Err(TemplateParseErrorKind::Expression(_)) ); }