#pragma once #include #include namespace spdlogconfig { // declaration section /** * Setup error with a textual description. * * This exception type is used to report configuration and initialization * failures within the spdlog configuration module. */ class spdlogconfig_error : public std::exception { public: /** * Construct an error from a C-string message. * * @param msg Error message to store. * @throw std::bad_alloc If memory allocation for the message fails. */ spdlogconfig_error(const char *const msg); /** * Construct an error from a std::string message. * * @param msg Error message to store (moved into this object). * @throw std::bad_alloc If memory allocation for the message fails. */ spdlogconfig_error(std::string msg); /** * Retrieve the stored error message. * * @return Null-terminated error message string. */ auto what() const noexcept -> const char * override; private: /** Stored error message text. */ std::string msg; }; // implementation section inline spdlogconfig_error::spdlogconfig_error(const char *const msg) : msg(msg) {} inline spdlogconfig_error::spdlogconfig_error(std::string msg) : msg(std::move(msg)) {} inline auto spdlogconfig_error::what() const noexcept -> const char * { return msg.c_str(); } } // namespace spdlogconfig