Base: Add Console::DestructorError as noexcept
Create a new console output that eats exceptions so it is safe to use in a destructor.
This commit is contained in:
committed by
Benjamin Nauck
parent
4bb372ef87
commit
67982f3963
@@ -26,6 +26,7 @@
|
||||
|
||||
// Std. configurations
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -759,6 +760,11 @@ public:
|
||||
template<typename... Args>
|
||||
inline void DeveloperError(const std::string& notifier, const char* pMsg, Args&&... args);
|
||||
template<typename... Args>
|
||||
/// A noexcept DeveloperError for use in destructors. When compiled in debug, terminates via an
|
||||
/// assert. In release, the exception is silently caught and dropped.
|
||||
inline void
|
||||
DestructorError(const std::string& notifier, const char* pMsg, Args&&... args) noexcept;
|
||||
template<typename... Args>
|
||||
inline void UserError(const std::string& notifier, const char* pMsg, Args&&... args);
|
||||
template<typename... Args>
|
||||
inline void TranslatedUserError(const std::string& notifier, const char* pMsg, Args&&... args);
|
||||
@@ -1083,6 +1089,21 @@ inline void Base::ConsoleSingleton::DeveloperError(const std::string& notifier,
|
||||
Base::ContentType::Untranslatable>(notifier, pMsg, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void Base::ConsoleSingleton::DestructorError(const std::string& notifier,
|
||||
const char* pMsg,
|
||||
Args&&... args) noexcept
|
||||
{
|
||||
try {
|
||||
Send<Base::LogStyle::Error,
|
||||
Base::IntendedRecipient::Developer,
|
||||
Base::ContentType::Untranslatable>(notifier, pMsg, std::forward<Args>(args)...);
|
||||
}
|
||||
catch (...) {
|
||||
assert("An exception was thrown while attempting console output in a destructor" && false);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void
|
||||
Base::ConsoleSingleton::UserError(const std::string& notifier, const char* pMsg, Args&&... args)
|
||||
|
||||
Reference in New Issue
Block a user