From 04e8c1c1441ed4f11b2cb8a22041a778bdaa35d4 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 8 Dec 2025 13:28:17 +0900 Subject: [PATCH] commands: extend parser errors --- src/commands.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 2f9095e4..1e9197b3 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -34,6 +34,7 @@ pub use playback_options::*; pub use querying_mpd_status::*; pub use queue::*; pub use reflection::*; +use serde::{Deserialize, Serialize}; pub use stickers::*; pub use stored_playlists::*; @@ -488,19 +489,30 @@ pub(crate) use single_item_command_request; pub(crate) use single_item_command_response; pub(crate) use single_optional_item_command_request; -#[derive(Debug, Clone, PartialEq)] +#[derive(Error, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum RequestParserError { + #[error("Could not parse the request due to a syntax error at position {0}: {1}")] SyntaxError(u64, String), + + #[error("A command list was expected to be closed, but the end was not found at line {0}")] MissingCommandListEnd(u64), + + #[error("A command list was found inside another command list at line {0}")] NestedCommandList(u64), + + #[error("A command list was closed unexpectedly at line {0}")] UnexpectedCommandListEnd(u64), + + #[error("Request ended early, while more arguments were expected")] UnexpectedEOF, - MissingNewline, + + // #[error("Request is missing terminating newline")] + // MissingNewline, } // TODO: should these be renamed to fit the mpd docs? // "Attribute" instead of "Property"? -#[derive(Error, Debug, Clone, PartialEq)] +#[derive(Error, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum ResponseParserError { #[error("A property was expected to be present in the response, but was not found: {0}")] MissingProperty(String), @@ -525,6 +537,8 @@ pub enum ResponseParserError { #[error("Response ended early, while more properties were expected")] UnexpectedEOF, + + // #[error("Response is missing terminating newline")] // MissingNewline, }