diff --git a/src/PlaylistPrint.cxx b/src/PlaylistPrint.cxx index 8789f5b22..44df5dc0c 100644 --- a/src/PlaylistPrint.cxx +++ b/src/PlaylistPrint.cxx @@ -46,7 +46,7 @@ playlist_print_uris(Response &r, Partition &partition, queue_print_uris(r, partition, queue, 0, queue.GetLength()); } -bool +void playlist_print_info(Response &r, Partition &partition, const playlist &playlist, unsigned start, unsigned end) @@ -59,13 +59,12 @@ playlist_print_info(Response &r, Partition &partition, if (start > end) /* an invalid "start" offset is fatal */ - return false; + throw PlaylistError::BadRange(); queue_print_info(r, partition, queue, start, end); - return true; } -bool +void playlist_print_id(Response &r, Partition &partition, const playlist &playlist, unsigned id) { @@ -74,10 +73,10 @@ playlist_print_id(Response &r, Partition &partition, const playlist &playlist, position = playlist.queue.IdToPosition(id); if (position < 0) /* no such song */ - return false; + throw PlaylistError::NoSuchSong(); - return playlist_print_info(r, partition, - playlist, position, position + 1); + playlist_print_info(r, partition, + playlist, position, position + 1); } bool diff --git a/src/PlaylistPrint.hxx b/src/PlaylistPrint.hxx index 346c4c6d2..ae1693366 100644 --- a/src/PlaylistPrint.hxx +++ b/src/PlaylistPrint.hxx @@ -41,8 +41,10 @@ playlist_print_uris(Response &r, Partition &partition, * information about the songs. The "end" offset is decreased * automatically if it is too large; passing UINT_MAX is allowed. * This function however fails when the start offset is invalid. + * + * Throws #PlaylistError if the range is invalid. */ -bool +void playlist_print_info(Response &r, Partition &partition, const playlist &playlist, unsigned start, unsigned end); @@ -50,9 +52,9 @@ playlist_print_info(Response &r, Partition &partition, /** * Sends the song with the specified id to the client. * - * @return true on suite, false if there is no such song + * Throws #PlaylistError if the range is invalid. */ -bool +void playlist_print_id(Response &r, Partition &partition, const playlist &playlist, unsigned id); diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx index bae8cdea4..26a3e222c 100644 --- a/src/command/QueueCommands.cxx +++ b/src/command/QueueCommands.cxx @@ -251,11 +251,8 @@ handle_playlistinfo(Client &client, Request args, Response &r) { RangeArg range = args.ParseOptional(0, RangeArg::All()); - if (!playlist_print_info(r, client.partition, client.playlist, - range.start, range.end)) - return print_playlist_result(r, - PlaylistResult::BAD_RANGE); - + playlist_print_info(r, client.partition, client.playlist, + range.start, range.end); return CommandResult::OK; } @@ -264,10 +261,8 @@ handle_playlistid(Client &client, Request args, Response &r) { if (!args.IsEmpty()) { unsigned id = args.ParseUnsigned(0); - bool ret = playlist_print_id(r, client.partition, - client.playlist, id); - if (!ret) - return print_playlist_result(r, PlaylistResult::NO_SUCH_SONG); + playlist_print_id(r, client.partition, + client.playlist, id); } else { playlist_print_info(r, client.partition, client.playlist, 0, std::numeric_limits::max());