diff --git a/golem-rib/src/expr.rs b/golem-rib/src/expr.rs index 548cdeecfc..74bddd5c07 100644 --- a/golem-rib/src/expr.rs +++ b/golem-rib/src/expr.rs @@ -68,8 +68,9 @@ impl Expr { /// Rib supports conditional calls, function calls, pattern-matching, /// string interpolation (see error_message above) etc. /// - pub fn from_str(input: &str) -> Result> { + pub fn from_str(input: &str) -> Result { rib_program().easy_parse(input.as_ref()).map(|(expr, _)| expr) + .map_err(|err| err.to_string()) } /// Parse an interpolated text as Rib expression. The input is always expected to be wrapped with `${..}` @@ -117,9 +118,9 @@ impl Expr { /// if foo > 1 then bar else "baz-${user.id}" /// ``` /// - pub fn from_interpolated_str(input: &str) -> Result> { + pub fn from_interpolated_str(input: &str) -> Result { let input = format!("\"{}\"", input); - rib_program().easy_parse(input.as_ref()).map(|(expr, _)| expr) + Self::from_str(input.as_str()) } pub fn unsigned_integer(u64: u64) -> Expr { Expr::Number(Number::Unsigned(u64)) diff --git a/golem-rib/src/text/mod.rs b/golem-rib/src/text/mod.rs index 67e70f34b5..798755218a 100644 --- a/golem-rib/src/text/mod.rs +++ b/golem-rib/src/text/mod.rs @@ -20,7 +20,7 @@ mod writer; use crate::text::writer::WriterError; use combine::stream::easy; -pub fn from_string(input: &str) -> Result> { +pub fn from_string(input: &str) -> Result { Expr::from_str(input.as_ref()) }