playlist/Length: throw PlaylistError::NoSuchList instead of returning false
This commit is contained in:
parent
c974fc664c
commit
a5456a89dc
|
@ -164,11 +164,8 @@ handle_playlistlength(Client &client, Request args, Response &r)
|
|||
#endif
|
||||
);
|
||||
|
||||
if (playlist_file_length(r, client.GetPartition(), SongLoader(client),
|
||||
name))
|
||||
return CommandResult::OK;
|
||||
|
||||
throw PlaylistError::NoSuchList();
|
||||
playlist_file_length(r, client.GetPartition(), SongLoader(client), name);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "thread/Mutex.hxx"
|
||||
#include "Partition.hxx"
|
||||
#include "Instance.hxx"
|
||||
#include "PlaylistError.hxx"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
|
@ -45,10 +46,10 @@ playlist_provider_length(Response &r,
|
|||
r.Fmt(FMT_STRING("playtime: {}\n"), playtime.RoundS());
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
playlist_file_length(Response &r, Partition &partition,
|
||||
const SongLoader &loader,
|
||||
const LocatedUri &uri)
|
||||
const SongLoader &loader,
|
||||
const LocatedUri &uri)
|
||||
{
|
||||
Mutex mutex;
|
||||
|
||||
|
@ -62,8 +63,7 @@ playlist_file_length(Response &r, Partition &partition,
|
|||
#endif
|
||||
mutex);
|
||||
if (playlist == nullptr)
|
||||
return false;
|
||||
throw PlaylistError::NoSuchList();
|
||||
|
||||
playlist_provider_length(r, loader, uri.canonical_uri, *playlist);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#ifndef MPD_PLAYLIST__LENGTH_HXX
|
||||
#define MPD_PLAYLIST__LENGTH_HXX
|
||||
#pragma once
|
||||
|
||||
#include "client/Response.hxx"
|
||||
|
||||
|
@ -13,12 +12,12 @@ struct Partition;
|
|||
* Count the number of songs and their total playtime (seconds) in the
|
||||
* playlist.
|
||||
*
|
||||
* Throws on error.
|
||||
*
|
||||
* @param uri the URI of the playlist file in UTF-8 encoding
|
||||
* @return true on success, false if the playlist does not exist
|
||||
*/
|
||||
bool
|
||||
void
|
||||
playlist_file_length(Response &r, Partition &partition,
|
||||
const SongLoader &loader,
|
||||
const LocatedUri &uri);
|
||||
|
||||
#endif
|
||||
const SongLoader &loader,
|
||||
const LocatedUri &uri);
|
||||
|
|
Loading…
Reference in New Issue