diff --git a/src/commands/music_database/count.rs b/src/commands/music_database/count.rs index c1322f7..a410554 100644 --- a/src/commands/music_database/count.rs +++ b/src/commands/music_database/count.rs @@ -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 diff --git a/src/commands/music_database/getfingerprint.rs b/src/commands/music_database/getfingerprint.rs index 848dfeb..7296778 100644 --- a/src/commands/music_database/getfingerprint.rs +++ b/src/commands/music_database/getfingerprint.rs @@ -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()); diff --git a/src/commands/music_database/list.rs b/src/commands/music_database/list.rs index 6cf84e2..0ca8ef5 100644 --- a/src/commands/music_database/list.rs +++ b/src/commands/music_database/list.rs @@ -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::, ResponseParserError>>()?; diff --git a/src/commands/music_database/listall.rs b/src/commands/music_database/listall.rs index ae02ef6..8156772 100644 --- a/src/commands/music_database/listall.rs +++ b/src/commands/music_database/listall.rs @@ -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()?; diff --git a/src/commands/music_database/listallinfo.rs b/src/commands/music_database/listallinfo.rs index d4344d6..49a8adb 100644 --- a/src/commands/music_database/listallinfo.rs +++ b/src/commands/music_database/listallinfo.rs @@ -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()?; diff --git a/src/commands/music_database/listfiles.rs b/src/commands/music_database/listfiles.rs index 1e61486..241d310 100644 --- a/src/commands/music_database/listfiles.rs +++ b/src/commands/music_database/listfiles.rs @@ -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()?; diff --git a/src/commands/music_database/lsinfo.rs b/src/commands/music_database/lsinfo.rs index dfa2945..601804c 100644 --- a/src/commands/music_database/lsinfo.rs +++ b/src/commands/music_database/lsinfo.rs @@ -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()?; diff --git a/src/commands/music_database/readcomments.rs b/src/commands/music_database/readcomments.rs index c7b53d6..73236f6 100644 --- a/src/commands/music_database/readcomments.rs +++ b/src/commands/music_database/readcomments.rs @@ -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()); diff --git a/src/commands/music_database/searchcount.rs b/src/commands/music_database/searchcount.rs index b0edd2b..a9bd6e9 100644 --- a/src/commands/music_database/searchcount.rs +++ b/src/commands/music_database/searchcount.rs @@ -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 diff --git a/src/commands/stickers/sticker_list.rs b/src/commands/stickers/sticker_list.rs index 66add21..7d51045 100644 --- a/src/commands/stickers/sticker_list.rs +++ b/src/commands/stickers/sticker_list.rs @@ -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());