Removed exceptions completely

This commit is contained in:
Jack Andersen 2015-08-24 21:01:00 -10:00
parent 34f2f028a9
commit 154b844130
1 changed files with 0 additions and 39 deletions

View File

@ -7,8 +7,6 @@
#include <vector> #include <vector>
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include <locale>
#include <codecvt>
namespace LogVisor namespace LogVisor
{ {
@ -17,35 +15,6 @@ namespace LogVisor
#define LOG_UCS2 1 #define LOG_UCS2 1
#endif #endif
#if LOG_VISOR_EXCEPTIONS
/**
* @brief Exception thrown when FatalError is issued
*/
class FatalException : public std::exception
{
std::string m_what;
public:
FatalException(const char* format, va_list ap)
{
char buf[1024];
vsnprintf(buf, 1024, format, ap);
m_what.assign(buf);
}
FatalException(const wchar_t* format, va_list ap)
{
wchar_t buf[1024];
vswprintf(buf, 1024, format, ap);
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
m_what.assign(conv.to_bytes(buf));
}
#if _MSC_VER
inline const char* what() const {return m_what.c_str();}
#else
inline const char* what() const noexcept {return m_what.c_str();}
#endif
};
#endif
/** /**
* @brief Severity level for log messages * @brief Severity level for log messages
*/ */
@ -166,11 +135,7 @@ public:
for (auto& logger : MainLoggers) for (auto& logger : MainLoggers)
logger->report(m_modName, severity, format, ap); logger->report(m_modName, severity, format, ap);
if (severity == FatalError) if (severity == FatalError)
#if LOG_VISOR_EXCEPTIONS
throw FatalException(format, ap);
#else
abort(); abort();
#endif
else if (severity == Error) else if (severity == Error)
++ErrorCount; ++ErrorCount;
} }
@ -197,11 +162,7 @@ public:
for (auto& logger : MainLoggers) for (auto& logger : MainLoggers)
logger->reportSource(m_modName, severity, file, linenum, format, ap); logger->reportSource(m_modName, severity, file, linenum, format, ap);
if (severity == FatalError) if (severity == FatalError)
#if LOG_VISOR_EXCEPTIONS
throw FatalException(format, ap);
#else
abort(); abort();
#endif
else if (severity == Error) else if (severity == Error)
++ErrorCount; ++ErrorCount;
} }