From 781e690012512e72bbfa101cba584787ddd212be Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Fri, 21 Sep 2018 17:35:32 +0200
Subject: [PATCH] player/Thread: catch and log initialization errors

---
 src/player/Thread.cxx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index 8ef278fd8..19869e981 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -1098,7 +1098,7 @@ do_play(PlayerControl &pc, DecoderControl &dc,
 
 void
 PlayerControl::RunThread() noexcept
-{
+try {
 	SetThreadName("player");
 
 	DecoderControl dc(mutex, cond,
@@ -1185,4 +1185,12 @@ PlayerControl::RunThread() noexcept
 			break;
 		}
 	}
+} catch (...) {
+	/* exceptions caught here are thrown during initialization;
+	   the main loop doesn't throw */
+
+	LogError(std::current_exception());
+
+	/* TODO: what now? How will the main thread learn about this
+	   failure? */
 }