refactor: check conn

pull/676/head
Alex 2020-05-24 18:47:50 +02:00
parent 9b9d13ab0d
commit 9a123052a0
1 changed files with 6 additions and 3 deletions

View File

@ -289,10 +289,13 @@ void waybar::modules::MPD::checkErrors(mpd_connection* conn) {
state_ = MPD_STATE_UNKNOWN;
throw std::runtime_error("Connection to MPD closed");
default:
if (conn) {
auto error_message = mpd_connection_get_error_message(conn);
mpd_connection_clear_error(conn);
throw std::runtime_error(std::string(error_message));
}
throw std::runtime_error("Invalid connection");
}
}
void waybar::modules::MPD::fetchState() {