From 33bb24ca6ba1a71f068b79b80b6388aa39d5184d Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 10 Aug 2006 11:59:29 +0000 Subject: Add a default exception handler around main() git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4829 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/inspircd.cpp') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index aaf20062f..4dc8cf03c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -961,15 +961,22 @@ int main(int argc, char** argv) try { - ServerInstance = new InspIRCd(argc, argv); - ServerInstance->Run(); - DELETE(ServerInstance); + try + { + ServerInstance = new InspIRCd(argc, argv); + ServerInstance->Run(); + DELETE(ServerInstance); + } + catch (std::bad_alloc) + { + log(SPARSE,"You are out of memory! (got exception std::bad_alloc!)"); + ServerInstance->SendError("**** OUT OF MEMORY **** We're gonna need a bigger boat!"); + } } - catch (std::bad_alloc) + catch (...) { - log(DEFAULT,"You are out of memory! (got exception std::bad_alloc!)"); - ServerInstance->SendError("**** OUT OF MEMORY **** We're gonna need a bigger boat!"); - printf("Out of memory! (got exception std::bad_alloc!"); + log(SPARSE,"Uncaught exception, aborting."); + ServerInstance->SendError("Server terminating due to uncaught exception."); } return 0; } -- cgit v1.3.1-10-gc9f91