command/{Player,Error}: extract messages from nested exceptions
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "db/DatabaseError.hxx"
|
||||
#include "client/Response.hxx"
|
||||
#include "Log.hxx"
|
||||
#include "util/Exception.hxx"
|
||||
|
||||
#include <system_error>
|
||||
|
||||
@@ -122,12 +123,6 @@ ToAck(std::exception_ptr ep)
|
||||
void
|
||||
PrintError(Response &r, std::exception_ptr ep)
|
||||
{
|
||||
try {
|
||||
std::rethrow_exception(ep);
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
r.Error(ToAck(ep), e.what());
|
||||
} catch (...) {
|
||||
r.Error(ACK_ERROR_UNKNOWN, "Unknown error");
|
||||
}
|
||||
LogError(ep);
|
||||
r.Error(ToAck(ep), FullMessage(ep).c_str());
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@
|
||||
#include "Idle.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/Exception.hxx"
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
#include "db/update/Service.hxx"
|
||||
@@ -192,10 +193,9 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
|
||||
|
||||
try {
|
||||
client.player_control.LockCheckRethrowError();
|
||||
} catch (const std::exception &e) {
|
||||
r.Format(COMMAND_STATUS_ERROR ": %s\n", e.what());
|
||||
} catch (...) {
|
||||
r.Format(COMMAND_STATUS_ERROR ": unknown\n");
|
||||
r.Format(COMMAND_STATUS_ERROR ": %s\n",
|
||||
FullMessage(std::current_exception()).c_str());
|
||||
}
|
||||
|
||||
song = playlist.GetNextPosition();
|
||||
|
Reference in New Issue
Block a user