fix(mpd): slightly better and safer error handling
This commit is contained in:
parent
0ce8821aec
commit
3656035c89
|
@ -38,7 +38,8 @@ auto waybar::modules::MPD::update() -> void {
|
||||||
if (!wasPlaying && playing()) {
|
if (!wasPlaying && playing()) {
|
||||||
periodic_updater().detach();
|
periodic_updater().detach();
|
||||||
}
|
}
|
||||||
} catch (std::exception e) {
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << module_name_ + ": " + e.what() << std::endl;
|
||||||
state_ = MPD_STATE_UNKNOWN;
|
state_ = MPD_STATE_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,11 @@ std::thread waybar::modules::MPD::event_listener() {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (connection_ == nullptr) {
|
if (connection_ == nullptr) {
|
||||||
// Retry periodically if no connection
|
// Retry periodically if no connection
|
||||||
|
try {
|
||||||
update();
|
update();
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << module_name_ + ": " + e.what() << std::endl;
|
||||||
|
}
|
||||||
std::this_thread::sleep_for(interval_);
|
std::this_thread::sleep_for(interval_);
|
||||||
} else {
|
} else {
|
||||||
waitForEvent();
|
waitForEvent();
|
||||||
|
|
Loading…
Reference in New Issue