fix(battery): Crash when format-low not defined

This was a backwards-incompatible change introduced in #2199, however it
was caused because `module_formatter.has` throws an exception when the
format doesn't exist instead of just returning false.

Fixes #2262
Ref #2199
This commit is contained in:
patrick96 2020-12-03 11:46:09 +01:00 committed by Patrick Ziegler
parent 1168ef36a0
commit bc87eb3b69

View File

@ -152,7 +152,7 @@ namespace modules {
bool module_formatter::has(const string& tag, const string& format_name) { bool module_formatter::has(const string& tag, const string& format_name) {
auto format = m_formats.find(format_name); auto format = m_formats.find(format_name);
if (format == m_formats.end()) { if (format == m_formats.end()) {
throw undefined_format(format_name); return false;
} }
return format->second->value.find(tag) != string::npos; return format->second->value.find(tag) != string::npos;
} }