diff --git a/src/utils/command.rs b/src/utils/command.rs index 6a247c78..c79a5c85 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -46,6 +46,7 @@ //! [examples/admin_bot]: https://github.com/teloxide/teloxide/blob/master/examples/admin_bot/ pub use teloxide_macros::BotCommand; +use std::error::Error; /// An enumeration of bot's commands. /// @@ -161,13 +162,14 @@ pub use teloxide_macros::BotCommand; /// len => Err(ParseError::Custom(format!( /// "Only 2 digits allowed, not {}", /// len -/// ))), +/// ).into())), /// } /// } /// /// #[derive(BotCommand, PartialEq, Debug)] -/// #[command(rename = "lowercase", parser = "split")] +/// #[command(rename = "lowercase")] /// enum Command { +/// #[command(parser = "accept_two_digits")] /// Num(u8), /// } /// @@ -217,7 +219,7 @@ pub enum ParseError { WrongBotName(String), /// A custom error which you can return from your custom parser. - Custom(String), + Custom(Box), } /// Parses a string into a command with args. diff --git a/tests/command.rs b/tests/command.rs index 0e3aaefc..a45482f8 100644 --- a/tests/command.rs +++ b/tests/command.rs @@ -132,7 +132,7 @@ fn parse_custom_parser() { _ => return Err(ParseError::IncorrectFormat), }; left.parse::().map(|res| (res, right.to_string())).map_err(|_| { - ParseError::Custom("First argument must be a integer!".to_owned()) + ParseError::Custom("First argument must be a integer!".to_owned().into()) }) }