commands: fix some syntax errors reporting literals
This commit is contained in:
parent
9cef59eb88
commit
366f56da9e
@ -23,12 +23,12 @@ impl Command for Count {
|
||||
let filter = parse_filter(&mut parts)?;
|
||||
|
||||
let group = if let Some("group") = parts.next() {
|
||||
let group = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
|
||||
Some(
|
||||
parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
group
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "group".to_owned()))?,
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, group.to_owned()))?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
|
@ -19,7 +19,7 @@ impl Command for GetFingerprint {
|
||||
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let uri = uri
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))?;
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, uri.to_owned()))?;
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
|
@ -18,7 +18,7 @@ impl Command for List {
|
||||
let tagtype = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let tagtype = tagtype
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "tagtype".to_owned()))?;
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, tagtype.to_owned()))?;
|
||||
|
||||
// TODO: This should be optional
|
||||
let filter = parse_filter(&mut parts)?;
|
||||
@ -28,7 +28,7 @@ impl Command for List {
|
||||
Some(
|
||||
group
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "group".to_owned()))?,
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, group.to_owned()))?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
@ -50,11 +50,11 @@ impl Command for List {
|
||||
let list = parts
|
||||
.0
|
||||
.iter()
|
||||
.map(|(_, v)| match v {
|
||||
.map(|(k, v)| match v {
|
||||
GenericResponseValue::Text(value) => Ok(value.to_string()),
|
||||
GenericResponseValue::Binary(_) => Err(
|
||||
ResponseParserError::UnexpectedPropertyType("handler", "Binary"),
|
||||
),
|
||||
GenericResponseValue::Binary(_) => {
|
||||
Err(ResponseParserError::UnexpectedPropertyType(k, "Binary"))
|
||||
}
|
||||
})
|
||||
.collect::<Result<Vec<_>, ResponseParserError>>()?;
|
||||
|
||||
|
@ -17,7 +17,7 @@ impl Command for ListAll {
|
||||
.next()
|
||||
.map(|s| {
|
||||
s.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
|
@ -18,7 +18,7 @@ impl Command for ListAllInfo {
|
||||
.next()
|
||||
.map(|s| {
|
||||
s.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
|
@ -17,7 +17,7 @@ impl Command for ListFiles {
|
||||
.next()
|
||||
.map(|s| {
|
||||
s.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
|
@ -17,7 +17,7 @@ impl Command for LsInfo {
|
||||
.next()
|
||||
.map(|s| {
|
||||
s.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, s.to_owned()))
|
||||
})
|
||||
.transpose()?;
|
||||
|
||||
|
@ -17,7 +17,7 @@ impl Command for ReadComments {
|
||||
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let uri = uri
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))?;
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, uri.to_owned()))?;
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
|
@ -23,12 +23,11 @@ impl Command for SearchCount {
|
||||
let filter = parse_filter(&mut parts)?;
|
||||
|
||||
let group = if let Some("group") = parts.next() {
|
||||
let group = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
Some(
|
||||
parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
group
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "group".to_owned()))?,
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, group.to_owned()))?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
|
@ -17,12 +17,12 @@ impl Command for StickerList {
|
||||
let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let sticker_type = sticker_type
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "sticker_type".to_owned()))?;
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, sticker_type.to_owned()))?;
|
||||
|
||||
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let uri = uri
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, "uri".to_owned()))?;
|
||||
.map_err(|_| RequestParserError::SyntaxError(1, uri.to_owned()))?;
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user