mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-08 21:48:08 +00:00
fileset: consolidate signature of invalid arguments error constructors
For the same reason as the templater changes. These FunctionCallNode types will be extracted as utility type.
This commit is contained in:
parent
7a230395c2
commit
2143cc3686
1 changed files with 9 additions and 11 deletions
|
@ -122,16 +122,13 @@ impl FilesetParseError {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unexpected number of arguments, or invalid combination of arguments.
|
/// Unexpected number of arguments, or invalid combination of arguments.
|
||||||
pub(super) fn invalid_arguments(
|
pub(super) fn invalid_arguments(name: &str, message: String, span: pest::Span<'_>) -> Self {
|
||||||
function: &FunctionCallNode,
|
|
||||||
message: impl Into<String>,
|
|
||||||
) -> Self {
|
|
||||||
FilesetParseError::new(
|
FilesetParseError::new(
|
||||||
FilesetParseErrorKind::InvalidArguments {
|
FilesetParseErrorKind::InvalidArguments {
|
||||||
name: function.name.to_owned(),
|
name: name.to_owned(),
|
||||||
message: message.into(),
|
message,
|
||||||
},
|
},
|
||||||
function.args_span,
|
span,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,12 +344,13 @@ impl<'i> FunctionCallNode<'i> {
|
||||||
if self.args.is_empty() {
|
if self.args.is_empty() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(FilesetParseError::invalid_arguments(
|
Err(self.invalid_arguments("Expected 0 arguments".to_owned()))
|
||||||
self,
|
|
||||||
"Expected 0 arguments",
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn invalid_arguments(&self, message: String) -> FilesetParseError {
|
||||||
|
FilesetParseError::invalid_arguments(self.name, message, self.args_span)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue