summaryrefslogtreecommitdiff
path: root/src/logger.cpp
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
committerReid <reidyaro@gmail.com>2012-03-01 22:03:01 +0100
commit490862919d79369112c75955a9c36ff8a081efd3 (patch)
tree6fe89466b9c53ba811f298174e6d787bbae71e09 /src/logger.cpp
parentdff814619d63496acd3c4e8730b828b5d4d931fb (diff)
parentd873da3e8e57480016596f714845c1bc7e712e68 (diff)
downloadmanaplus-490862919d79369112c75955a9c36ff8a081efd3.tar.gz
manaplus-490862919d79369112c75955a9c36ff8a081efd3.tar.bz2
manaplus-490862919d79369112c75955a9c36ff8a081efd3.tar.xz
manaplus-490862919d79369112c75955a9c36ff8a081efd3.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/logger.cpp')
-rw-r--r--src/logger.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/logger.cpp b/src/logger.cpp
index 1541616f2..9c9c6efef 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -189,7 +189,8 @@ void Logger::log(const char *log_text, ...)
delete [] buf;
}
-void Logger::error(const std::string &error_text)
+// here string must be safe for any usage
+void Logger::safeError(const std::string &error_text)
{
log("Error: %s", error_text.c_str());
#ifdef WIN32
@@ -214,3 +215,31 @@ void Logger::error(const std::string &error_text)
#endif
exit(1);
}
+
+// here string can be unsafe strings
+void Logger::error(const std::string &error_text)
+{
+ log("Error: %s", error_text.c_str());
+#ifdef WIN32
+ MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
+#elif defined __APPLE__
+// Str255 msg;
+// CFStringRef error;
+// error = CFStringCreateWithCString(nullptr,
+// error_text.c_str(),
+// kCFStringEncodingMacRoman);
+// CFStringGetPascalString(error, msg, 255, kCFStringEncodingMacRoman);
+// StandardAlert(kAlertStopAlert,
+// (const unsigned char*)"\pError",
+// (ConstStr255Param) msg, nullptr, nullptr);
+#elif defined __linux__ || __linux
+ std::cerr << "Error: " << error_text << std::endl;
+ std::string msg = "xmessage \"Error happend. "
+ "Please see log file for more information.\"";
+ if (system(msg.c_str()) == -1)
+ std::cerr << "Error: " << error_text << std::endl;
+#else
+ std::cerr << "Error: " << error_text << std::endl;
+#endif
+ exit(1);
+}