mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
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()) {
|
||||
periodic_updater().detach();
|
||||
}
|
||||
} catch (std::exception e) {
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << module_name_ + ": " + e.what() << std::endl;
|
||||
state_ = MPD_STATE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
@ -51,7 +52,11 @@ std::thread waybar::modules::MPD::event_listener() {
|
||||
while (true) {
|
||||
if (connection_ == nullptr) {
|
||||
// Retry periodically if no connection
|
||||
try {
|
||||
update();
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << module_name_ + ": " + e.what() << std::endl;
|
||||
}
|
||||
std::this_thread::sleep_for(interval_);
|
||||
} else {
|
||||
waitForEvent();
|
||||
|
Loading…
Reference in New Issue
Block a user