mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +00:00
revset: don't stringify StringPatternParseError
This helps to add hint at the CLI layer.
This commit is contained in:
parent
c4d48c5139
commit
d759ba11f1
2 changed files with 10 additions and 6 deletions
|
@ -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()"]);
|
||||
|
|
|
@ -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!(
|
||||
|
|
Loading…
Reference in a new issue