fix fatal error messages
This commit is contained in:
parent
f3c0260ea2
commit
f41e1e75cd
|
@ -22,14 +22,10 @@
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "eventdispatcher.h"
|
#include "eventdispatcher.h"
|
||||||
|
#include <framework/platform/platformwindow.h>
|
||||||
|
|
||||||
Logger g_logger;
|
Logger g_logger;
|
||||||
|
|
||||||
Logger::Logger()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Logger::log(Fw::LogLevel level, std::string message)
|
void Logger::log(Fw::LogLevel level, std::string message)
|
||||||
{
|
{
|
||||||
const static std::string logPrefixes[] = { "", "", "WARNING: ", "ERROR: ", "FATAL ERROR: " };
|
const static std::string logPrefixes[] = { "", "", "WARNING: ", "ERROR: ", "FATAL ERROR: " };
|
||||||
|
@ -43,8 +39,10 @@ void Logger::log(Fw::LogLevel level, std::string message)
|
||||||
if(m_onLog)
|
if(m_onLog)
|
||||||
m_onLog(level, message, now);
|
m_onLog(level, message, now);
|
||||||
|
|
||||||
if(level == Fw::LogFatal)
|
if(level == Fw::LogFatal) {
|
||||||
throw std::runtime_error(message);
|
g_window.displayFatalError(message);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction)
|
void Logger::logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction)
|
||||||
|
|
|
@ -37,8 +37,6 @@ class Logger
|
||||||
typedef std::function<void(Fw::LogLevel, std::string, std::size_t)> OnLogCallback;
|
typedef std::function<void(Fw::LogLevel, std::string, std::size_t)> OnLogCallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Logger();
|
|
||||||
|
|
||||||
void log(Fw::LogLevel level, std::string message);
|
void log(Fw::LogLevel level, std::string message);
|
||||||
void logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction);
|
void logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction);
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
virtual void poll() = 0;
|
virtual void poll() = 0;
|
||||||
virtual void swapBuffers() = 0;
|
virtual void swapBuffers() = 0;
|
||||||
virtual void showMouse() = 0;
|
virtual void showMouse() = 0;
|
||||||
|
virtual void displayFatalError(const std::string& message) { }
|
||||||
virtual void hideMouse() = 0;
|
virtual void hideMouse() = 0;
|
||||||
|
|
||||||
virtual void setTitle(const std::string& title) = 0;
|
virtual void setTitle(const std::string& title) = 0;
|
||||||
|
|
|
@ -618,3 +618,7 @@ std::string WIN32Window::getPlatformType()
|
||||||
return "WIN32-WGL";
|
return "WIN32-WGL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WIN32Window::displayFatalError(const std::string& message)
|
||||||
|
{
|
||||||
|
MessageBoxA(m_window, message.c_str(), "FATAL ERROR", MB_OK | MB_ICONERROR);
|
||||||
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ public:
|
||||||
void swapBuffers();
|
void swapBuffers();
|
||||||
void showMouse();
|
void showMouse();
|
||||||
void hideMouse();
|
void hideMouse();
|
||||||
|
void displayFatalError(const std::string& message);
|
||||||
|
|
||||||
void setTitle(const std::string& title);
|
void setTitle(const std::string& title);
|
||||||
void setMinimumSize(const Size& minimumSize);
|
void setMinimumSize(const Size& minimumSize);
|
||||||
|
|
Loading…
Reference in New Issue