diff --git a/include/MacStd/CoreFoundation.hpp b/include/MacStd/CoreFoundation.hpp index 134bf83..692e8f2 100644 --- a/include/MacStd/CoreFoundation.hpp +++ b/include/MacStd/CoreFoundation.hpp @@ -65,6 +65,26 @@ namespace macstd { { } + /// + /// Constructs an exception + /// + /// \param[in] error Core Foundation error + /// \param[in] msg Error message + /// + cf_runtime_error(CFErrorRef error, const std::string& msg) : + num_runtime_error(CFErrorGetCode(error), msg + ": " + message(error)), + m_error(error) + { + } + + /// + /// Constructs an exception + /// + /// \param[in] error Core Foundation error + /// \param[in] msg Error message + /// + cf_runtime_error(CFErrorRef error, const char* msg) : cf_runtime_error(error, std::string(msg)) {} + /// /// Constructs an exception /// @@ -76,6 +96,26 @@ namespace macstd { { } + /// + /// Constructs an exception + /// + /// \param[in] error Core Foundation error + /// \param[in] msg Error message + /// + cf_runtime_error(cferror&& error, const std::string& msg) : + num_runtime_error(CFErrorGetCode(error), msg + ": " + message(error)), + m_error(std::move(error)) + { + } + + /// + /// Constructs an exception + /// + /// \param[in] error Core Foundation error + /// \param[in] msg Error message + /// + cf_runtime_error(cferror&& error, const char* msg) : cf_runtime_error(std::move(error), std::string(msg)) {} + CFErrorRef cferror() const noexcept { return m_error; } protected: