command/Error: move code to ToAck(std::exception_ptr)
This commit is contained in:
parent
fe0b6a1117
commit
19e43087a8
@ -158,6 +158,23 @@ print_error(Response &r, const Error &error)
|
|||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
static enum ack
|
||||||
|
ToAck(std::exception_ptr ep)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
std::rethrow_exception(ep);
|
||||||
|
} catch (const ProtocolError &pe) {
|
||||||
|
return pe.GetCode();
|
||||||
|
} catch (const PlaylistError &pe) {
|
||||||
|
return ToAck(pe.GetCode());
|
||||||
|
} catch (const std::system_error &e) {
|
||||||
|
return ACK_ERROR_SYSTEM;
|
||||||
|
} catch (...) {
|
||||||
|
return ACK_ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintError(Response &r, std::exception_ptr ep)
|
PrintError(Response &r, std::exception_ptr ep)
|
||||||
{
|
{
|
||||||
@ -170,14 +187,8 @@ PrintError(Response &r, std::exception_ptr ep)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
std::rethrow_exception(ep);
|
std::rethrow_exception(ep);
|
||||||
} catch (const ProtocolError &pe) {
|
|
||||||
r.Error(pe.GetCode(), pe.what());
|
|
||||||
} catch (const PlaylistError &pe) {
|
|
||||||
r.Error(ToAck(pe.GetCode()), pe.what());
|
|
||||||
} catch (const std::system_error &e) {
|
|
||||||
r.Error(ACK_ERROR_SYSTEM, e.what());
|
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
r.Error(ACK_ERROR_UNKNOWN, e.what());
|
r.Error(ToAck(ep), e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
r.Error(ACK_ERROR_UNKNOWN, "Unknown error");
|
r.Error(ACK_ERROR_UNKNOWN, "Unknown error");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user