Skip to content

Commit

Permalink
fileset: consolidate signature of invalid arguments error constructors
Browse files Browse the repository at this point in the history
For the same reason as the templater changes. These FunctionCallNode types will
be extracted as utility type.
  • Loading branch information
yuja committed May 22, 2024
1 parent 7a23039 commit 2143cc3
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/src/fileset_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}

Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit 2143cc3

Please sign in to comment.