mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
Enhance an error message about a path
This commit is contained in:
parent
5d6cce4121
commit
6ae6b0024e
1 changed files with 10 additions and 7 deletions
|
@ -12,15 +12,18 @@ pub(crate) enum ParserType {
|
|||
|
||||
impl ParserType {
|
||||
pub fn parse(value: AttrValue) -> Result<Self> {
|
||||
value.expect(r#""default", "split" or a path"#, |v| match v {
|
||||
AttrValue::Path(p) => Ok(ParserType::Custom(p)),
|
||||
AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() {
|
||||
"default" => Ok(ParserType::Default),
|
||||
"split" => Ok(ParserType::Split { separator: None }),
|
||||
value.expect(
|
||||
r#""default", "split", or a path for custom parsers"#,
|
||||
|v| match v {
|
||||
AttrValue::Path(p) => Ok(ParserType::Custom(p)),
|
||||
AttrValue::Lit(syn::Lit::Str(ref l)) => match &*l.value() {
|
||||
"default" => Ok(ParserType::Default),
|
||||
"split" => Ok(ParserType::Split { separator: None }),
|
||||
_ => Err(v),
|
||||
},
|
||||
_ => Err(v),
|
||||
},
|
||||
_ => Err(v),
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue