From bc87eb3b69519c731499610b8ca9a731acaa2422 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Thu, 3 Dec 2020 11:46:09 +0100
Subject: [PATCH] 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
---
src/modules/meta/base.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/modules/meta/base.cpp b/src/modules/meta/base.cpp
index 43e57a11..f03010b4 100644
--- a/src/modules/meta/base.cpp
+++ b/src/modules/meta/base.cpp
@@ -152,7 +152,7 @@ namespace modules {
bool module_formatter::has(const string& tag, const string& format_name) {
auto format = m_formats.find(format_name);
if (format == m_formats.end()) {
- throw undefined_format(format_name);
+ return false;
}
return format->second->value.find(tag) != string::npos;
}