player/Control: convert error from Error to std::exception_ptr

Prepare full C++ exception support in the player thread.
This commit is contained in:
Max Kellermann
2016-09-08 10:21:34 +02:00
parent 6e52ab285a
commit 0ce72cbf9d
3 changed files with 38 additions and 23 deletions

View File

@@ -32,6 +32,7 @@
#include "AudioFormat.hxx"
#include "ReplayGainConfig.hxx"
#include "util/ScopeExit.hxx"
#include "util/Error.hxx"
#ifdef ENABLE_DATABASE
#include "db/update/Service.hxx"
@@ -191,10 +192,15 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
}
#endif
Error error = client.player_control.LockGetError();
if (error.IsDefined())
r.Format(COMMAND_STATUS_ERROR ": %s\n",
error.GetMessage());
try {
client.player_control.LockCheckRethrowError();
} catch (const std::exception &e) {
r.Format(COMMAND_STATUS_ERROR ": %s\n", e.what());
} catch (const Error &error) {
r.Format(COMMAND_STATUS_ERROR ": %s\n", error.GetMessage());
} catch (...) {
r.Format(COMMAND_STATUS_ERROR ": unknown\n");
}
song = playlist.GetNextPosition();
if (song >= 0)