playlist/Print: throw PlaylistError::NoSuchList instead of returning false
This commit is contained in:
parent
a5456a89dc
commit
9303764a83
|
@ -128,11 +128,9 @@ handle_listplaylist(Client &client, Request args, Response &r)
|
|||
|
||||
RangeArg range = args.ParseOptional(1, RangeArg::All());
|
||||
|
||||
if (playlist_file_print(r, client.GetPartition(), SongLoader(client),
|
||||
name, range.start, range.end, false))
|
||||
return CommandResult::OK;
|
||||
|
||||
throw PlaylistError::NoSuchList();
|
||||
playlist_file_print(r, client.GetPartition(), SongLoader(client),
|
||||
name, range.start, range.end, false);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
|
@ -147,11 +145,9 @@ handle_listplaylistinfo(Client &client, Request args, Response &r)
|
|||
|
||||
RangeArg range = args.ParseOptional(1, RangeArg::All());
|
||||
|
||||
if (playlist_file_print(r, client.GetPartition(), SongLoader(client),
|
||||
name, range.start, range.end, true))
|
||||
return CommandResult::OK;
|
||||
|
||||
throw PlaylistError::NoSuchList();
|
||||
playlist_file_print(r, client.GetPartition(), SongLoader(client),
|
||||
name, range.start, range.end, true);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "thread/Mutex.hxx"
|
||||
#include "Partition.hxx"
|
||||
#include "Instance.hxx"
|
||||
#include "PlaylistError.hxx"
|
||||
|
||||
static void
|
||||
playlist_provider_print(Response &r,
|
||||
|
@ -48,7 +49,7 @@ playlist_provider_print(Response &r,
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
playlist_file_print(Response &r, Partition &partition,
|
||||
const SongLoader &loader,
|
||||
const LocatedUri &uri,
|
||||
|
@ -68,9 +69,8 @@ playlist_file_print(Response &r, Partition &partition,
|
|||
#endif
|
||||
mutex);
|
||||
if (playlist == nullptr)
|
||||
return false;
|
||||
throw PlaylistError::NoSuchList();
|
||||
|
||||
playlist_provider_print(r, loader, uri.canonical_uri, *playlist,
|
||||
start_index, end_index, detail);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#ifndef MPD_PLAYLIST__PRINT_HXX
|
||||
#define MPD_PLAYLIST__PRINT_HXX
|
||||
#pragma once
|
||||
|
||||
class Response;
|
||||
class SongLoader;
|
||||
|
@ -11,15 +10,14 @@ struct Partition;
|
|||
/**
|
||||
* Send the playlist file to the client.
|
||||
*
|
||||
* Throws on error.
|
||||
*
|
||||
* @param uri the URI of the playlist file in UTF-8 encoding
|
||||
* @param detail true if all details should be printed
|
||||
* @return true on success, false if the playlist does not exist
|
||||
*/
|
||||
bool
|
||||
void
|
||||
playlist_file_print(Response &r, Partition &partition,
|
||||
const SongLoader &loader,
|
||||
const LocatedUri &uri,
|
||||
unsigned start_index, unsigned end_index,
|
||||
bool detail);
|
||||
|
||||
#endif
|
||||
unsigned start_index, unsigned end_index,
|
||||
bool detail);
|
||||
|
|
Loading…
Reference in New Issue