aboutsummaryrefslogtreecommitdiffstats
path: root/liblfjail/config_error.hh
diff options
context:
space:
mode:
authorLexi Winter <lexi@hemlock.eden.le-fay.org>2025-06-13 10:31:25 +0100
committerLexi Winter <lexi@hemlock.eden.le-fay.org>2025-06-13 10:31:25 +0100
commit722c03e547a1370857878ea7db27be6111aae8b1 (patch)
tree22544bc828275516f6068c9b048cc829672653bf /liblfjail/config_error.hh
parent1202c450ce3bea3a2fa0c8ba369dcc40c2f8626b (diff)
downloadlfjail-722c03e547a1370857878ea7db27be6111aae8b1.tar.gz
lfjail-722c03e547a1370857878ea7db27be6111aae8b1.tar.bz2
move utilities to liblfjail
Diffstat (limited to 'liblfjail/config_error.hh')
-rw-r--r--liblfjail/config_error.hh34
1 files changed, 34 insertions, 0 deletions
diff --git a/liblfjail/config_error.hh b/liblfjail/config_error.hh
new file mode 100644
index 0000000..c515b54
--- /dev/null
+++ b/liblfjail/config_error.hh
@@ -0,0 +1,34 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+#ifndef LFJAIL_CONFIG_ERROR_HH
+#define LFJAIL_CONFIG_ERROR_HH
+
+#include <format>
+#include <stdexcept>
+
+namespace lfjail::config {
+
+/*
+ * Exception thrown when an issue occurs with the configuration.
+ */
+struct error : std::runtime_error {
+ template<typename... Args>
+ error(std::format_string<Args...> fmt, Args &&...args)
+ : std::runtime_error(std::format(fmt, std::forward<Args>(args)...))
+ {}
+};
+
+struct unknown_setting final : error {
+ std::string varname;
+
+ unknown_setting(std::string_view varname_)
+ : error("unknown configuration variable '{0}'", varname_)
+ , varname(varname_)
+ {}
+};
+
+} // namespace lfjail::config
+
+#endif // !LFJAIL_CONFIG_ERROR_HH