Add NoEvents error for CmusQueryResponse

This commit is contained in:
Anas Elgarhy 2023-02-20 05:41:01 +02:00
parent 6d62c66b5f
commit 4773c1c1cd
No known key found for this signature in database
GPG key ID: 0501802A1D496528
3 changed files with 3 additions and 7 deletions

View file

@ -54,6 +54,8 @@ pub enum CmusError {
UnknownAAAMode(String), UnknownAAAMode(String),
#[error("Unknown shuffle mode: {0}")] #[error("Unknown shuffle mode: {0}")]
UnknownShuffleMode(String), UnknownShuffleMode(String),
#[error("No events")]
NoEvents,
} }
impl FromStr for TrackStatus { impl FromStr for TrackStatus {

View file

@ -51,7 +51,7 @@ impl CmusQueryResponse {
if self.track_row.is_empty() || self.player_settings_row.is_empty() { if self.track_row.is_empty() || self.player_settings_row.is_empty() {
#[cfg(feature = "debug")] #[cfg(feature = "debug")]
info!("Cmus response is empty, returning empty events"); info!("Cmus response is empty, returning empty events");
return Ok(Vec::new()); return Err(CmusError::NoEvents)
} }
let mut events = Vec::new(); let mut events = Vec::new();

View file

@ -30,12 +30,6 @@ impl NotificationsHandler {
events: Vec<CmusEvent>, events: Vec<CmusEvent>,
response: &CmusQueryResponse, response: &CmusQueryResponse,
) -> Result<(), notify_rust::error::Error> { ) -> Result<(), notify_rust::error::Error> {
if events.is_empty() {
#[cfg(feature = "debug")]
info!("no events to process");
return Ok(()); // No events to process.
}
//FIXME: Should check if the user has enabled the cover feature or use a static cover. //FIXME: Should check if the user has enabled the cover feature or use a static cover.
self.update_cover(&events[0], response); self.update_cover(&events[0], response);