From 0331a5fda419050b7eb019e0adb8fa2b102005ae Mon Sep 17 00:00:00 2001 From: Maxim Kolesnikov Date: Sun, 12 Jun 2022 21:31:11 +0700 Subject: [PATCH] fix: error reporting for deprecated config values (#2725) --- CHANGELOG.md | 1 + include/components/config.hpp | 5 +++++ src/components/bar.cpp | 7 +------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8955e4e5..09d47585 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Waiting for double click interval on modules that don't have a double click action ([`#2663`](https://github.com/polybar/polybar/issues/2663), [`#2695`](https://github.com/polybar/polybar/pull/2695)) +- Error reporting for deprecated config values ([`#2724`](https://github.com/polybar/polybar/issues/2724)) ## [3.6.3] - 2022-05-04 ### Fixed diff --git a/include/components/config.hpp b/include/components/config.hpp index 33936fdd..b3a894e6 100644 --- a/include/components/config.hpp +++ b/include/components/config.hpp @@ -226,6 +226,11 @@ class config { } catch (const key_error& err) { return get(section, newkey, fallback); } + catch (const std::exception& err) { + m_log.err("Invalid value for \"%s.%s\", using fallback key \"%s.%s\" (reason: %s)", + section, old, section, newkey, err.what()); + return get(section, newkey, fallback); + } } /** diff --git a/src/components/bar.cpp b/src/components/bar.cpp index aaabc391..04633556 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -131,12 +131,7 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const m_log.info("Loaded monitor %s (%ix%i+%i+%i)", m_opts.monitor->name, m_opts.monitor->w, m_opts.monitor->h, m_opts.monitor->x, m_opts.monitor->y); - try { - m_opts.override_redirect = m_conf.get(bs, "dock"); - m_conf.warn_deprecated(bs, "dock", "override-redirect"); - } catch (const key_error& err) { - m_opts.override_redirect = m_conf.get(bs, "override-redirect", m_opts.override_redirect); - } + m_opts.override_redirect = m_conf.deprecated(bs, "dock", "override-redirect", m_opts.override_redirect); m_opts.dimvalue = m_conf.get(bs, "dim-value", 1.0); m_opts.dimvalue = math_util::cap(m_opts.dimvalue, 0.0, 1.0);