From a1ef0159e3c1c4d4d66518f4f0b0af3945daf759 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 7 Feb 2016 12:18:58 +0100 Subject: [PATCH] playlist/PlaylistStream: catch and log C++ exceptions --- src/playlist/PlaylistStream.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/playlist/PlaylistStream.cxx b/src/playlist/PlaylistStream.cxx index 99e1c3182..ab3f00ee5 100644 --- a/src/playlist/PlaylistStream.cxx +++ b/src/playlist/PlaylistStream.cxx @@ -32,7 +32,7 @@ static SongEnumerator * playlist_open_path_suffix(Path path, Mutex &mutex, Cond &cond) -{ +try { assert(!path.IsNull()); const auto *suffix = path.GetSuffix(); @@ -58,11 +58,14 @@ playlist_open_path_suffix(Path path, Mutex &mutex, Cond &cond) delete is; return playlist; +} catch (const std::runtime_error &e) { + LogError(e); + return nullptr; } SongEnumerator * playlist_open_path(Path path, Mutex &mutex, Cond &cond) -{ +try { assert(!path.IsNull()); const std::string uri_utf8 = path.ToUTF8(); @@ -73,11 +76,14 @@ playlist_open_path(Path path, Mutex &mutex, Cond &cond) playlist = playlist_open_path_suffix(path, mutex, cond); return playlist; +} catch (const std::runtime_error &e) { + LogError(e); + return nullptr; } SongEnumerator * playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond) -{ +try { assert(uri_has_scheme(uri)); SongEnumerator *playlist = playlist_list_open_uri(uri, mutex, cond); @@ -100,4 +106,7 @@ playlist_open_remote(const char *uri, Mutex &mutex, Cond &cond) } return new CloseSongEnumerator(playlist, is); +} catch (const std::runtime_error &e) { + LogError(e); + return nullptr; }