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