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