aboutsummaryrefslogtreecommitdiff
path: root/src/server/bnetserver/Main.cpp
diff options
context:
space:
mode:
authorDuarte Duarte <dnpd.dd@gmail.com>2015-02-15 14:56:12 +0000
committerDuarte Duarte <dnpd.dd@gmail.com>2015-02-15 14:56:12 +0000
commite68ca82d4d039a401d03de145111b0a738bb9dd7 (patch)
treebaee33aa8cc4babf3ef391bc73d0ee3e827fb1dc /src/server/bnetserver/Main.cpp
parentad53be708162cf277af6ae2f391e40fcf4b81333 (diff)
Core/Server: Catch exceptions in int main()
The exceptions is rethrown on debug mode. Ref Coverity CID 1010213, 1022574, 1227501, 1227502, 1227503, 1227504, 1227505, 1254536 and 1254612
Diffstat (limited to 'src/server/bnetserver/Main.cpp')
-rw-r--r--src/server/bnetserver/Main.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/server/bnetserver/Main.cpp b/src/server/bnetserver/Main.cpp
index 5f4f63287e5..ab7c91512e2 100644
--- a/src/server/bnetserver/Main.cpp
+++ b/src/server/bnetserver/Main.cpp
@@ -61,7 +61,7 @@ boost::asio::deadline_timer _dbPingTimer(_ioService);
uint32 _dbPingInterval;
LoginDatabaseWorkerPool LoginDatabase;
-int main(int argc, char** argv)
+int mainImpl(int argc, char** argv)
{
std::string configFile = _TRINITY_BNET_CONFIG;
auto vm = GetConsoleArguments(argc, argv, configFile);
@@ -156,6 +156,23 @@ int main(int argc, char** argv)
return 0;
}
+int main(int argc, char** argv)
+{
+ try
+ {
+ return mainImpl(argc, argv);
+ }
+ catch (std::exception& ex)
+ {
+ std::cerr << "Top-level exception caught:" << ex.what() << "\n";
+
+#ifndef NDEBUG // rethrow exception for the debugger
+ throw;
+#else
+ return 1;
+#endif
+ }
+}
/// Initialize connection to the database
bool StartDB()