From f41e1e75cde26d8a2073be155d2cfc70ca0155f1 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 6 Jan 2012 18:15:41 -0200 Subject: [PATCH] fix fatal error messages --- src/framework/core/logger.cpp | 12 +++++------- src/framework/core/logger.h | 2 -- src/framework/platform/platformwindow.h | 1 + src/framework/platform/win32window.cpp | 4 ++++ src/framework/platform/win32window.h | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/framework/core/logger.cpp b/src/framework/core/logger.cpp index bcaf599a..ee572880 100644 --- a/src/framework/core/logger.cpp +++ b/src/framework/core/logger.cpp @@ -22,14 +22,10 @@ #include "logger.h" #include "eventdispatcher.h" +#include Logger g_logger; -Logger::Logger() -{ - -} - void Logger::log(Fw::LogLevel level, std::string message) { 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) m_onLog(level, message, now); - if(level == Fw::LogFatal) - throw std::runtime_error(message); + if(level == Fw::LogFatal) { + g_window.displayFatalError(message); + exit(-1); + } } void Logger::logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction) diff --git a/src/framework/core/logger.h b/src/framework/core/logger.h index 7d11d9c1..0b144489 100644 --- a/src/framework/core/logger.h +++ b/src/framework/core/logger.h @@ -37,8 +37,6 @@ class Logger typedef std::function OnLogCallback; public: - Logger(); - void log(Fw::LogLevel level, std::string message); void logFunc(Fw::LogLevel level, const std::string& message, std::string prettyFunction); diff --git a/src/framework/platform/platformwindow.h b/src/framework/platform/platformwindow.h index 133ffe4c..cc2c25fe 100644 --- a/src/framework/platform/platformwindow.h +++ b/src/framework/platform/platformwindow.h @@ -43,6 +43,7 @@ public: virtual void poll() = 0; virtual void swapBuffers() = 0; virtual void showMouse() = 0; + virtual void displayFatalError(const std::string& message) { } virtual void hideMouse() = 0; virtual void setTitle(const std::string& title) = 0; diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index 0201a2d2..5820bcdf 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -618,3 +618,7 @@ std::string WIN32Window::getPlatformType() return "WIN32-WGL"; } +void WIN32Window::displayFatalError(const std::string& message) +{ + MessageBoxA(m_window, message.c_str(), "FATAL ERROR", MB_OK | MB_ICONERROR); +} diff --git a/src/framework/platform/win32window.h b/src/framework/platform/win32window.h index 6408b80b..6d8de9f3 100644 --- a/src/framework/platform/win32window.h +++ b/src/framework/platform/win32window.h @@ -58,6 +58,7 @@ public: void swapBuffers(); void showMouse(); void hideMouse(); + void displayFatalError(const std::string& message); void setTitle(const std::string& title); void setMinimumSize(const Size& minimumSize);