From 90aa957ca9b7c217af7569009d1675e0f3ff8e9b Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Thu, 26 Jun 2025 20:47:45 +0100 Subject: ucl, config: use monadic error handling more --- nihil.config/store.ccm | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'nihil.config/store.ccm') diff --git a/nihil.config/store.ccm b/nihil.config/store.ccm index 77b44b5..03d09d3 100644 --- a/nihil.config/store.ccm +++ b/nihil.config/store.ccm @@ -9,51 +9,50 @@ module; */ #include +#include #include #include export module nihil.config:store; import nihil; -import :error; import :option; namespace nihil::config { -// Exception thrown on an attempt to fetch an undefined option. -export struct unknown_option final : error { - unknown_option(std::string_view option_name); - auto option_name(this unknown_option const &self) -> std::string_view; - -private: - std::string _option_name; -}; - struct store final { /* * Get the global config store. */ - static auto get() -> store &; + [[nodiscard]] static auto get() -> store &; /* * Register a new value with the config store. */ - auto register_option(this store &self, option *object) -> void; + [[nodiscard]] auto register_option(this store &, option *object) + -> std::expected; /* * Remove a value from the config store. */ - auto unregister_option(this store &self, option *object) -> void; + [[nodiscard]] auto unregister_option(this store &, option *object) + -> std::expected; /* * Fetch an existing value in the config store. */ - auto fetch(this store const &self, std::string_view name) -> option &; + [[nodiscard]] auto fetch(this store const &, std::string_view name) + -> std::expected