mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-09 05:50:36 +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.
|
||||
pub(super) fn invalid_arguments(
|
||||
function: &FunctionCallNode,
|
||||
message: impl Into<String>,
|
||||
) -> Self {
|
||||
pub(super) fn invalid_arguments(name: &str, message: String, span: pest::Span<'_>) -> Self {
|
||||
FilesetParseError::new(
|
||||
FilesetParseErrorKind::InvalidArguments {
|
||||
name: function.name.to_owned(),
|
||||
message: message.into(),
|
||||
name: name.to_owned(),
|
||||
message,
|
||||
},
|
||||
function.args_span,
|
||||
span,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -347,12 +344,13 @@ impl<'i> FunctionCallNode<'i> {
|
|||
if self.args.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(FilesetParseError::invalid_arguments(
|
||||
self,
|
||||
"Expected 0 arguments",
|
||||
))
|
||||
Err(self.invalid_arguments("Expected 0 arguments".to_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
fn invalid_arguments(&self, message: String) -> FilesetParseError {
|
||||
FilesetParseError::invalid_arguments(self.name, message, self.args_span)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue