summaryrefslogtreecommitdiff
path: root/src/queue
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-02-28 10:40:31 +0100
committerMax Kellermann <max@duempel.org>2016-02-28 10:40:31 +0100
commitc81747dd153bbbdfd6de0ca18287047a749e9ddd (patch)
tree407fa8ed4137ecfcd62ca0ca3a5297076a2e8cf1 /src/queue
parentf8810d7caf55a4071b7288e03745fd0a9d1b84d3 (diff)
queue/PlaylistTag: throw PlaylistError on error
Diffstat (limited to 'src/queue')
-rw-r--r--src/queue/Playlist.hxx5
-rw-r--r--src/queue/PlaylistTag.cxx43
2 files changed, 16 insertions, 32 deletions
diff --git a/src/queue/Playlist.hxx b/src/queue/Playlist.hxx
index cd82b4b11..1abfb56a2 100644
--- a/src/queue/Playlist.hxx
+++ b/src/queue/Playlist.hxx
@@ -258,9 +258,8 @@ public:
SongTime start, SongTime end,
Error &error);
- bool AddSongIdTag(unsigned id, TagType tag_type, const char *value,
- Error &error);
- bool ClearSongIdTag(unsigned id, TagType tag_type, Error &error);
+ void AddSongIdTag(unsigned id, TagType tag_type, const char *value);
+ void ClearSongIdTag(unsigned id, TagType tag_type);
void Stop(PlayerControl &pc);
diff --git a/src/queue/PlaylistTag.cxx b/src/queue/PlaylistTag.cxx
index e61381bc1..08d66810a 100644
--- a/src/queue/PlaylistTag.cxx
+++ b/src/queue/PlaylistTag.cxx
@@ -29,25 +29,18 @@
#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
-#include "util/Error.hxx"
-bool
-playlist::AddSongIdTag(unsigned id, TagType tag_type, const char *value,
- Error &error)
+void
+playlist::AddSongIdTag(unsigned id, TagType tag_type, const char *value)
{
const int position = queue.IdToPosition(id);
- if (position < 0) {
- error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
- "No such song");
- return false;
- }
+ if (position < 0)
+ throw PlaylistError::NoSuchSong();
DetachedSong &song = queue.Get(position);
- if (song.IsFile()) {
- error.Set(playlist_domain, int(PlaylistResult::DENIED),
- "Cannot edit tags of local file");
- return false;
- }
+ if (song.IsFile())
+ throw PlaylistError(PlaylistResult::DENIED,
+ "Cannot edit tags of local file");
{
TagBuilder tag(std::move(song.WritableTag()));
@@ -57,26 +50,19 @@ playlist::AddSongIdTag(unsigned id, TagType tag_type, const char *value,
queue.ModifyAtPosition(position);
OnModified();
- return true;
}
-bool
-playlist::ClearSongIdTag(unsigned id, TagType tag_type,
- Error &error)
+void
+playlist::ClearSongIdTag(unsigned id, TagType tag_type)
{
const int position = queue.IdToPosition(id);
- if (position < 0) {
- error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
- "No such song");
- return false;
- }
+ if (position < 0)
+ throw PlaylistError::NoSuchSong();
DetachedSong &song = queue.Get(position);
- if (song.IsFile()) {
- error.Set(playlist_domain, int(PlaylistResult::DENIED),
- "Cannot edit tags of local file");
- return false;
- }
+ if (song.IsFile())
+ throw PlaylistError(PlaylistResult::DENIED,
+ "Cannot edit tags of local file");
{
TagBuilder tag(std::move(song.WritableTag()));
@@ -89,5 +75,4 @@ playlist::ClearSongIdTag(unsigned id, TagType tag_type,
queue.ModifyAtPosition(position);
OnModified();
- return true;
}