playlist/{Stream,Mapper,Any}: propagate exceptions, do not catch&log them
Let the caller handle all the exceptions.
This commit is contained in:
parent
9303764a83
commit
f53cd44c7a
|
@ -10,6 +10,7 @@
|
|||
#include "SongPrint.hxx"
|
||||
#include "song/DetachedSong.hxx"
|
||||
#include "song/LightSong.hxx"
|
||||
#include "input/Error.hxx"
|
||||
#include "fs/Traits.hxx"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "Partition.hxx"
|
||||
|
@ -50,7 +51,7 @@ void
|
|||
playlist_file_length(Response &r, Partition &partition,
|
||||
const SongLoader &loader,
|
||||
const LocatedUri &uri)
|
||||
{
|
||||
try {
|
||||
Mutex mutex;
|
||||
|
||||
#ifndef ENABLE_DATABASE
|
||||
|
@ -66,4 +67,9 @@ playlist_file_length(Response &r, Partition &partition,
|
|||
throw PlaylistError::NoSuchList();
|
||||
|
||||
playlist_provider_length(r, loader, uri.canonical_uri, *playlist);
|
||||
} catch (...) {
|
||||
if (IsFileNotFound(std::current_exception()))
|
||||
throw PlaylistError::NoSuchList();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#ifndef MPD_PLAYLIST_ANY_HXX
|
||||
#define MPD_PLAYLIST_ANY_HXX
|
||||
#pragma once
|
||||
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "config.h"
|
||||
|
@ -16,6 +15,10 @@ class Storage;
|
|||
* Opens a playlist from the specified URI, which can be either an
|
||||
* absolute remote URI (with a scheme) or a relative path to the
|
||||
* music or playlist directory.
|
||||
*
|
||||
* Throws on error.
|
||||
*
|
||||
* @return a playlist, or nullptr if the file is not supported
|
||||
*/
|
||||
std::unique_ptr<SongEnumerator>
|
||||
playlist_open_any(const LocatedUri &located_uri,
|
||||
|
@ -23,5 +26,3 @@ playlist_open_any(const LocatedUri &located_uri,
|
|||
const Storage *storage,
|
||||
#endif
|
||||
Mutex &mutex);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#ifndef MPD_PLAYLIST_MAPPER_HXX
|
||||
#define MPD_PLAYLIST_MAPPER_HXX
|
||||
#pragma once
|
||||
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "config.h"
|
||||
|
@ -15,6 +14,10 @@ class Storage;
|
|||
/**
|
||||
* Opens a playlist from an URI relative to the playlist or music
|
||||
* directory.
|
||||
*
|
||||
* Throws on error.
|
||||
*
|
||||
* @return a playlist, or nullptr if the file is not supported
|
||||
*/
|
||||
std::unique_ptr<SongEnumerator>
|
||||
playlist_mapper_open(const char *uri,
|
||||
|
@ -22,5 +25,3 @@ playlist_mapper_open(const char *uri,
|
|||
const Storage *storage,
|
||||
#endif
|
||||
Mutex &mutex);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "queue/Playlist.hxx"
|
||||
#include "SongEnumerator.hxx"
|
||||
#include "song/DetachedSong.hxx"
|
||||
#include "input/Error.hxx"
|
||||
#include "thread/Mutex.hxx"
|
||||
#include "fs/Traits.hxx"
|
||||
#include "Log.hxx"
|
||||
|
@ -61,7 +62,7 @@ playlist_open_into_queue(const LocatedUri &uri,
|
|||
unsigned start_index, unsigned end_index,
|
||||
playlist &dest, PlayerControl &pc,
|
||||
const SongLoader &loader)
|
||||
{
|
||||
try {
|
||||
Mutex mutex;
|
||||
|
||||
auto playlist = playlist_open_any(uri,
|
||||
|
@ -75,4 +76,9 @@ playlist_open_into_queue(const LocatedUri &uri,
|
|||
playlist_load_into_queue(uri.canonical_uri, *playlist,
|
||||
start_index, end_index,
|
||||
dest, pc, loader);
|
||||
} catch (...) {
|
||||
if (IsFileNotFound(std::current_exception()))
|
||||
throw PlaylistError::NoSuchList();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
// Copyright The Music Player Daemon Project
|
||||
|
||||
#pragma once
|
||||
|
||||
/*! \file
|
||||
* \brief Glue between playlist plugin and the play queue
|
||||
*/
|
||||
|
||||
#ifndef MPD_PLAYLIST_QUEUE_HXX
|
||||
#define MPD_PLAYLIST_QUEUE_HXX
|
||||
|
||||
class SongLoader;
|
||||
class SongEnumerator;
|
||||
struct playlist;
|
||||
|
@ -31,12 +30,11 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
|
|||
/**
|
||||
* Opens a playlist with a playlist plugin and append to the specified
|
||||
* play queue.
|
||||
*
|
||||
* Throws on error.
|
||||
*/
|
||||
void
|
||||
playlist_open_into_queue(const LocatedUri &uri,
|
||||
unsigned start_index, unsigned end_index,
|
||||
playlist &dest, PlayerControl &pc,
|
||||
const SongLoader &loader);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,14 +8,13 @@
|
|||
#include "input/LocalOpen.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/UriExtract.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <exception>
|
||||
|
||||
static std::unique_ptr<SongEnumerator>
|
||||
playlist_open_path_suffix(Path path, Mutex &mutex)
|
||||
try {
|
||||
{
|
||||
assert(!path.IsNull());
|
||||
|
||||
const auto *suffix = path.GetExtension();
|
||||
|
@ -29,14 +28,11 @@ try {
|
|||
auto is = OpenLocalInputStream(path, mutex);
|
||||
return playlist_list_open_stream_suffix(std::move(is),
|
||||
suffix_utf8);
|
||||
} catch (...) {
|
||||
LogError(std::current_exception());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<SongEnumerator>
|
||||
playlist_open_path(Path path, Mutex &mutex)
|
||||
try {
|
||||
{
|
||||
assert(!path.IsNull());
|
||||
|
||||
const std::string uri_utf8 = path.ToUTF8Throw();
|
||||
|
@ -45,14 +41,11 @@ try {
|
|||
playlist = playlist_open_path_suffix(path, mutex);
|
||||
|
||||
return playlist;
|
||||
} catch (...) {
|
||||
LogError(std::current_exception());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<SongEnumerator>
|
||||
playlist_open_remote(const char *uri, Mutex &mutex)
|
||||
try {
|
||||
{
|
||||
assert(uri_has_scheme(uri));
|
||||
|
||||
auto playlist = playlist_list_open_uri(uri, mutex);
|
||||
|
@ -61,7 +54,4 @@ try {
|
|||
|
||||
auto is = InputStream::OpenReady(uri, mutex);
|
||||
return playlist_list_open_stream(std::move(is), uri);
|
||||
} catch (...) {
|
||||
LogError(std::current_exception());
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ class Path;
|
|||
/**
|
||||
* Opens a playlist from a local file.
|
||||
*
|
||||
* Throws on error.
|
||||
*
|
||||
* @param path the path of the playlist file
|
||||
* @return a playlist, or nullptr on error
|
||||
* @return a playlist, or nullptr if the file is not supported
|
||||
*/
|
||||
std::unique_ptr<SongEnumerator>
|
||||
playlist_open_path(Path path, Mutex &mutex);
|
||||
|
@ -22,8 +24,10 @@ playlist_open_path(Path path, Mutex &mutex);
|
|||
/**
|
||||
* Opens a playlist from a remote file.
|
||||
*
|
||||
* Throws on error.
|
||||
*
|
||||
* @param uri the absolute URI of the playlist file
|
||||
* @return a playlist, or nullptr on error
|
||||
* @return a playlist, or nullptr if the file is not supported
|
||||
*/
|
||||
[[gnu::nonnull]]
|
||||
std::unique_ptr<SongEnumerator>
|
||||
|
|
Loading…
Reference in New Issue