aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-27 17:27:23 +0100
committerMax Kellermann <max@duempel.org>2014-02-27 17:27:23 +0100
commit1c772ef69947127e01e7171b007a2295d51e7ae7 (patch)
tree1461d15b1f94e29ef23a750b97dcf16d77de9fd5 /src/command
parent809b89b5af5eaf7abc3240d786cda15f354b6624 (diff)
downloadmpd-1c772ef69947127e01e7171b007a2295d51e7ae7.tar.gz
mpd-1c772ef69947127e01e7171b007a2295d51e7ae7.tar.xz
mpd-1c772ef69947127e01e7171b007a2295d51e7ae7.zip
Playlist: use the Error library to return errors
Diffstat (limited to 'src/command')
-rw-r--r--src/command/PlaylistCommands.cxx14
-rw-r--r--src/command/QueueCommands.cxx20
2 files changed, 17 insertions, 17 deletions
diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx
index 35dc0ceb3..bc426db4e 100644
--- a/src/command/PlaylistCommands.cxx
+++ b/src/command/PlaylistCommands.cxx
@@ -66,16 +66,14 @@ handle_load(Client &client, int argc, char *argv[])
} else if (!check_range(client, &start_index, &end_index, argv[2]))
return CommandResult::ERROR;
+ Error error;
const SongLoader loader(client);
- const PlaylistResult result =
- playlist_open_into_queue(argv[1],
- start_index, end_index,
- client.playlist,
- client.player_control, loader);
- if (result != PlaylistResult::NO_SUCH_LIST)
- return print_playlist_result(client, result);
+ if (!playlist_open_into_queue(argv[1],
+ start_index, end_index,
+ client.playlist,
+ client.player_control, loader, error))
+ return print_error(client, error);
- Error error;
if (playlist_load_spl(client.playlist, client.player_control,
argv[1], start_index, end_index,
error))
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx
index 105a33ebb..81e5098bb 100644
--- a/src/command/QueueCommands.cxx
+++ b/src/command/QueueCommands.cxx
@@ -64,8 +64,12 @@ handle_add(Client &client, gcc_unused int argc, char *argv[])
if (uri_has_scheme(uri) || PathTraitsUTF8::IsAbsolute(uri)) {
const SongLoader loader(client);
- auto result = client.partition.AppendURI(loader, uri);
- return print_playlist_result(client, result);
+ Error error;
+ unsigned id = client.partition.AppendURI(loader, uri, error);
+ if (id == 0)
+ return print_error(client, error);
+
+ return CommandResult::OK;
}
#ifdef ENABLE_DATABASE
@@ -88,18 +92,16 @@ handle_addid(Client &client, int argc, char *argv[])
return CommandResult::ERROR;
const SongLoader loader(client);
-
- unsigned added_id;
- auto result = client.partition.AppendURI(loader, uri, &added_id);
-
- if (result != PlaylistResult::SUCCESS)
- return print_playlist_result(client, result);
+ Error error;
+ unsigned added_id = client.partition.AppendURI(loader, uri, error);
+ if (added_id == 0)
+ return print_error(client, error);
if (argc == 3) {
unsigned to;
if (!check_unsigned(client, &to, argv[2]))
return CommandResult::ERROR;
- result = client.partition.MoveId(added_id, to);
+ PlaylistResult result = client.partition.MoveId(added_id, to);
if (result != PlaylistResult::SUCCESS) {
CommandResult ret =
print_playlist_result(client, result);