From f8810d7caf55a4071b7288e03745fd0a9d1b84d3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 28 Feb 2016 10:38:17 +0100 Subject: [PATCH] PlaylistError: add NotPlaying() --- src/PlaylistError.hxx | 5 +++++ src/queue/PlaylistControl.cxx | 15 ++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/PlaylistError.hxx b/src/PlaylistError.hxx index 7929e066e..64945b0d2 100644 --- a/src/PlaylistError.hxx +++ b/src/PlaylistError.hxx @@ -64,6 +64,11 @@ public: return PlaylistError(PlaylistResult::BAD_RANGE, "Bad song index"); } + + static PlaylistError NotPlaying() { + return PlaylistError(PlaylistResult::NOT_PLAYING, + "Not playing"); + } }; #endif diff --git a/src/queue/PlaylistControl.cxx b/src/queue/PlaylistControl.cxx index 563d0c766..5310a0fa1 100644 --- a/src/queue/PlaylistControl.cxx +++ b/src/queue/PlaylistControl.cxx @@ -260,22 +260,15 @@ playlist::SeekCurrent(PlayerControl &pc, SignedSongTime seek_time, bool relative, Error &error) { - if (!playing) { - error.Set(playlist_domain, int(PlaylistResult::NOT_PLAYING), - "Not playing"); - return false; - } + if (!playing) + throw PlaylistError::NotPlaying(); if (relative) { const auto status = pc.LockGetStatus(); if (status.state != PlayerState::PLAY && - status.state != PlayerState::PAUSE) { - error.Set(playlist_domain, - int(PlaylistResult::NOT_PLAYING), - "Not playing"); - return false; - } + status.state != PlayerState::PAUSE) + throw PlaylistError::NotPlaying(); seek_time += status.elapsed_time; if (seek_time.IsNegative())