Skip to content

Commit

Permalink
add field to UnknownChoice error
Browse files Browse the repository at this point in the history
  • Loading branch information
vidhanio committed Dec 5, 2023
1 parent 9870be3 commit 0cb1998
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion macros/src/basic_option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ impl Args {

match #choice_expr {
#(#arms)*
_ => ::std::result::Result::Err(::serenity_commands::Error::UnknownChoice),
unknown => ::std::result::Result::Err(
::serenity_commands::Error::UnknownChoice(
::std::string::ToString::to_string(unknown)
)
)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ pub enum Error {
MissingRequiredCommandOption,

/// An unknown choice was provided.
#[error("unknown choice")]
UnknownChoice,
#[error("unknown choice: {0}")]
UnknownChoice(String),

/// An error occurred within a custom implementation.
#[error(transparent)]
Expand Down

0 comments on commit 0cb1998

Please sign in to comment.