commands: fix some syntax errors reporting literals
Some checks failed
Build and test / build (push) Successful in 59s
Build and test / check (push) Failing after 58s
Build and test / docs (push) Successful in 1m21s
Build and test / test (push) Successful in 1m37s

This commit is contained in:
Oystein Kristoffer Tveit 2024-12-14 00:19:25 +01:00
parent 9cef59eb88
commit 366f56da9e
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
10 changed files with 21 additions and 22 deletions

View File

@ -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

View File

@ -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());

View File

@ -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>>()?;

View File

@ -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()?;

View File

@ -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()?;

View File

@ -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()?;

View File

@ -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()?;

View File

@ -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());

View File

@ -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

View File

@ -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());