diff --git a/cli/tests/test_revset_output.rs b/cli/tests/test_revset_output.rs index 03e4f3e3a..86a558cd0 100644 --- a/cli/tests/test_revset_output.rs +++ b/cli/tests/test_revset_output.rs @@ -167,13 +167,15 @@ fn test_bad_function_call() { let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", "branches(bad:pattern)"]); insta::assert_snapshot!(stderr, @r###" - Error: Failed to parse revset: Function "branches": Invalid string pattern kind "bad:", try prefixing with one of `exact:`, `glob:` or `substring:` - Caused by: --> 1:10 + Error: Failed to parse revset: Function "branches": Invalid string pattern + Caused by: + 1: --> 1:10 | 1 | branches(bad:pattern) | ^---------^ | - = Function "branches": Invalid string pattern kind "bad:", try prefixing with one of `exact:`, `glob:` or `substring:` + = Function "branches": Invalid string pattern + 2: Invalid string pattern kind "bad:", try prefixing with one of `exact:`, `glob:` or `substring:` "###); let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", "root()::whatever()"]); diff --git a/lib/src/revset.rs b/lib/src/revset.rs index cc30dfa1f..de61b438c 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -1449,8 +1449,10 @@ fn parse_function_argument_to_string_pattern( } RevsetExpression::StringPattern { kind, value } => { // TODO: error span can be narrowed to the lhs node - StringPattern::from_str_kind(value, kind) - .map_err(|err| RevsetParseError::invalid_arguments(name, err.to_string(), span))? + StringPattern::from_str_kind(value, kind).map_err(|err| { + RevsetParseError::invalid_arguments(name, "Invalid string pattern", span) + .with_source(err) + })? } _ => { return Err(RevsetParseError::invalid_arguments( @@ -2926,7 +2928,7 @@ mod tests { parse(r#"branches(bad:"foo")"#), Err(RevsetParseErrorKind::InvalidFunctionArguments { name: "branches".to_owned(), - message: r#"Invalid string pattern kind "bad:", try prefixing with one of `exact:`, `glob:` or `substring:`"#.to_owned() + message: "Invalid string pattern".to_owned() }) ); assert_eq!(