mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 01:30:13 +00:00
fix(commands): add separate missing error for Token::Any to relay a better error message to user
This commit is contained in:
parent
8a01d7d37a
commit
58b5a26eca
3 changed files with 20 additions and 3 deletions
|
|
@ -48,6 +48,7 @@ pub enum Token {
|
|||
#[derive(Debug)]
|
||||
pub enum TokenMatchError {
|
||||
MissingParameter { name: ParamName },
|
||||
MissingAny { tokens: Vec<Token> },
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -108,8 +109,9 @@ impl Token {
|
|||
Some(Err(TokenMatchError::MissingParameter { name: param_name }))
|
||||
}
|
||||
Self::Any(tokens) => tokens.is_empty().then_some(None).unwrap_or_else(|| {
|
||||
let mut results = tokens.iter().map(|t| t.try_match(None));
|
||||
results.find(|r| !matches!(r, None)).unwrap_or(None)
|
||||
Some(Err(TokenMatchError::MissingAny {
|
||||
tokens: tokens.clone(),
|
||||
}))
|
||||
}),
|
||||
// everything else doesnt match if no input anyway
|
||||
Token::Value(_) => None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue