]> git.hungrycats.org Git - bees/commitdiff
config: move THROW_CONFIG_ERROR to bees-config.h
authorZygo Blaxell <bees@furryterror.org>
Sun, 3 May 2026 07:56:56 +0000 (03:56 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 5 Sep 2026 04:03:58 +0000 (00:03 -0400)
This provides external config readers (e.g. BeesFilter) a standard
method to report configuration parse errors.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-config.cc
src/bees-config.h

index 08ed39c205c0a408c5f681a414461ad6f041134e..fd8328c264aeb837fe2e634180229b702ce38660 100644 (file)
 #include <sstream>
 #include <sys/statfs.h>
 
-#define THROW_CONFIG_ERROR(__key, __value, __message) do { \
-       ostringstream __oss; \
-       __oss << "configuration error: " << __key << " = \"" << __value << "\": " << __message; \
-       throw invalid_argument(__oss.str()); \
-} while (false)
+unique_ptr<BeesConfig::DefaultMap> BeesConfig::s_defaults;
 
-unique_ptr<map<string, Innie>> BeesConfig::s_defaults;
 
 BeesConfig::Register::Register::Register(const char *const version, const char *const text)
 {
index d6a388c03082a91182b011e14d4f52a898f678c4..8b4aa7bc3edcbd87da199fe736ae98cbc80c72c0 100644 (file)
@@ -178,3 +178,13 @@ double bees_parse_duration(const string& str);
 double bees_parse_ratio(const string& str);
 
 /// @}
+
+/**
+ * Throw a @c std::invalid_argument exception formatted as a configuration error.
+ * Includes the key and the offending value in the message.
+ */
+#define THROW_CONFIG_ERROR(__key, __value, __message) do { \
+       std::ostringstream __oss; \
+       __oss << "configuration error: " << (__key) << " = \"" << (__value) << "\": " << (__message); \
+       throw std::invalid_argument(__oss.str()); \
+} while (false)